Question

In: Computer Science

Using Python coding language (with or without Pandas and/or NumPy), 1. Can you define function sleep...

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.)

Solutions

Expert Solution

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!!


Related Solutions

#Python program using loop instead of numpy or pandas. Write a function to enter n student...
#Python program using loop instead of numpy or pandas. Write a function to enter n student scores from 0 to 100 to represent student score, Count how many A (100 - 90), B(89-80), C(79-70), D(69-60), F(<60) We will use numpy array OR pandas later for this problem, for now use loop Invoke the function with 10 student scores, show the result as follow: Test Enter 10 scores Enter a student score: 99 Enter a student score: 88 Enter a student...
Create and Compile a Python Script without using Numpy that Generate an nxn matrix using Python...
Create and Compile a Python Script without using Numpy that Generate an nxn matrix using Python Script (ie n=user input) Ask (user input ) and (randomly generated) row and column location Assign Q to (known row and column location ) and 0 to all others location Please show compile script working as well
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data from a CSV file, which has no names, just numbers. All I did was to read a .csv file. How do I pull data from three columns which contains about 1500 rows with just numbers and make a scatter plot with two in the x-axis and the third in the y-axis?
Using python as the coding language please write the code for the following problem. Write a...
Using python as the coding language please write the code for the following problem. Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness. First Argument Value Second Argument Value Return Value "coarse" "rounded" "intermediate" "coarse"...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. 2. Write a python program using Pandas to convert a Panda module Series to Python list and print it's type. (Hint: use ds.tolist() to convert the pandas series ds to a list) 3. Create a pandas dataframe called **my_df** with index as integer numbers between 0 to 10, first column (titled "rnd_int") as 10 integer random numbers between...
Write a python function (Without using external libraries) to calculate the 1). determinate of a 2...
Write a python function (Without using external libraries) to calculate the 1). determinate of a 2 x 2 matrix 2). Calculate the inverse of a 2 x 2 matrix.
MIPS ASSEMBLY LANGUAGE (I'm using MARS) Can you provide me with the code of this, without...
MIPS ASSEMBLY LANGUAGE (I'm using MARS) Can you provide me with the code of this, without using DIV (4a-b)%[(2+c)/d] (a,b,c,d are user inputs)
How to create a divide function in (Dr Racket) programming language without using the built in...
How to create a divide function in (Dr Racket) programming language without using the built in function " / " ?
Using python coding, test for convergence of an infinite sequence or series. keep the coding at...
Using python coding, test for convergence of an infinite sequence or series. keep the coding at beginner level please!
Python has an established coding style, but the style is a suggestion, and although you can...
Python has an established coding style, but the style is a suggestion, and although you can style your code using different style choices, you are strongly encouraged to be consistent. true or false
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT