Homework 2-2

This homework asks you write a program that takes in input from the command line, and prints out the basic metabolic rate and daily recommended intake in calories for the program's user.

Task 1

Your program should prompt the user for several different inputs. Feel free to phrase the questions however you want, but they should query the user for:

  • Their name
  • Their age in years
  • Their height in inches
  • Their weight in pounds
  • A value from 0-4 indicating their exercise level (0 is no weekly exercise, and 4 is very heavy exercise)

Task 2

Convert their age to seconds. It might be helpful to convert it to days first, then hours, then minutes, and lastly seconds.

Using the conversion of 1 inch to 2.54 centimeters, convert their height to cm.

Using the conversion of 2.2 pound per kilogram, convert their weight to kilograms.

Calculate the Basic Metabolic Rate for Men, which is estimated by
BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) + 5

Calculate the Basic Metabolic Rate for Women, which is estimated by
BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age in years) - 161

These formulas require the user's age in years, not seconds, so be sure to use the original age in years.

Task 4

Calculate their daily recommended intake, which can be estimated from
DRI = BMR * (1.2 + (0.175 * activity level))

Task 5

In a nicely formatted and well-worded paragraph, print the following using string concatenation:

  • Their name
  • Their age in seconds
  • Their height in centimeters
  • Their weight in kilograms
  • Their Basic Metabolic Rate if they are a man
  • Their Basic Metabolic Rate if they are a woman
  • Their Daily Recommended Intake if they are a man
  • Their Daily Recommended Intake if they are a woman

Here is an example of the programming running. Try these sample inputs to ensure that you get similar results

Task 6: Hours worked

Please put the number of hours you worked on this assignment, whether you went to TA hours and any students you collaborated with.

Extra Credit

As with every homework, you are welcome to expand on the tasks above for extra credit. For example, can you improve your program so that by asking an additional question, your program will only need to compute a single BMR and DRI specific to the user's gender? Alternatively, regardless of the user's chosen activity level, can you find a way to limit the actual range to 0-4 (e.ge: if they input 5, it gets converted automatically to 4, or -2 to 0)? Lastly, you could also choose to additionally implement another calculator based on the given information above, like BMI, target heart rate, etc.

Handin

Once you're done, upload your Python script to your google drive and share it with cs0030handin@gmail.com by midnight, 2/27.

Make sure your submission has your name in the filename: FirstLast_HW2-1.py. “FirstLast” should be replaced with your first and last name or we will take off points. Make sure every task has been completed.