In: Computer Science
Using Python coding language (with or without Pandas and/or NumPy),
1. Can you define function sleep to tell whether the participant are of the ages through 18 to 60 and sleep less than 6 hours per day?
2. Develop codes to check whether the sleep function you defined can make correct judgement. Make sure you write comments or create informative vairable name so that I can understand how you check the sleep function. (Hints: You can create toy data/dataframe to check the function.)
Solution: Above-given problem has been solved using the Python programming language and the code is up and running. Please find attached the code for the same down below:
Code:
#Taking the age and the sleeping hours of the person as the input
age = int(input("Enter the age of the person: "))
sleeping_hours = int(input('Enter the number of hours person slept:
'))
if( age > 18 and age < 60): #Checking the age of the
person
if sleeping_hours < 6: #Checking the amount of sleep the person
had last night
print("The person slept for less than 6 hours per day")
else:
print('The person slept for atleast 6 hours per day')
else:
print('The person is a kid')
Screenshot:
Here's the solution to your question, please provide it a 100% rating. Thanks for asking and happy learning!!