In the given examples, what you type is in red and the program prints what is in black. The symbol ↵ means a carriage return (return, enter).
Your program output should look like the output in the examples, except that what you type won’t be in red.
For all records of people between those ages (inclusive,) print the following statistics:
To turn in: Please turn in the program in the file med1.py.
Example 1:
Age from . . . 20↵ Age up to and including . . . 30↵ For ages 20-30, there are 48 males and 51 females: Height: minimum 145, mean 159.66, maximum 178 Weight: minimum 5, mean 77.79, maximum 161 Systolic blood pressure: minimum 110, mean 134.32, maximum 160 Diastolic blood pressure: minimum 70, mean 87.23, maximum 105 Disease categories: Cancer: 9 Diabetes: 8 Healthy: 13 Heart Disease: 23 Hypertension: 12 Nephrology: 11 Stroke: 23
Example 2:
Age from . . . 70↵ Age up to and including . . . 60↵ You put the bigger value in ’from’ . . . reversing them For ages 60-70, there are 48 males and 48 females: Height: minimum 145, mean 160.34, maximum 178 Weight: minimum 6, mean 85.44, maximum 166 Systolic blood pressure: minimum 110, mean 135.83, maximum 159 Diastolic blood pressure: minimum 70, mean 87.88, maximum 105 Disease categories: Cancer: 12 Diabetes: 18 Healthy: 10 Heart Disease: 9 Hypertension: 17 Nephrology: 16 Stroke: 14
Example 3:
Age from . . . -3↵
Please enter a positive integer
Example4:
Age from . . . 3↵ Age up to and including . . . hello↵ Please enter a positive integer
Make sure your function is recursive! Also, you only need to write the function; you do not need to write anything that calls the function.
To turn in: Please call your function listdepth, your file listdepth.py, and submit it to Canvas
Example 1:
listdepth( [ 3, [ 4, 5 ], [ 6, [ 7, [ 8 ] ] ] ])
4
Example 2:
listdepth( [ [ [ [ [ [ [ ] ] ] ] ] ] ])
7
Example 3:
listdepth([ "hello [ there ]" ])
1
Example 4:
listdepth(5)
Should never get here – called listdepth on non-list
Find the bug(s) and fix it (them). Put in your comments what you changed.
Hint: The function to round a number x to two places is round(x, 2).
To turn in: Please turn in the program in the file ftok-fixed.py.
Example 1, from the correctly working program:
Enter temperature in degrees Fahrenheit> 100↵
100.0 Fahrenheit is 310.93 Kelvin
Example 2, from the correctly working program:
Enter temperature in degrees Fahrenheit> -459.67↵
-459.67 Fahrenheit is 0.0 Kelvin
Example 3, from the correctly working program:
Enter temperature in degrees Fahrenheit> -600↵
That temperature is below 0 Kelvin, which is impossible
|
MHI 289I, Programming in Health Informatics Version of October 19, 2025 at 10:35PM
|
You can also obtain a PDF version of this. |