Rutgers University**We aren't endorsed by this school
Course
CS 110
Subject
Computer Science
Date
Dec 16, 2024
Pages
5
Uploaded by UltraInternet15746
CS110 – Principles of Computer ScienceAssignment #9FALL 2024 - Python Project #5Due dateFriday, November 15th, 2024, 11:59pmAccept Until DateFriday, November 22nd, 2024, 11:59pmEvaluation20 pointsSubmit to CanvasONE Python program (.py file)Related MaterialsPython Reference Guide posted in CanvasNeed help?TA office hours and Lab Support Schedule posted in CanvasYOU ARE ON YOUR HONOR TO COMPLETE THIS ASSIGNMENT WITHOUT ASSISTANCE. You may use your text and resources available to you through Canvas. You MAY NOT ask any human for assistance, give assistance to anyone, or use any online tutoring or AI service.BackgroundThe basal metabolic rate (BMR) is the amount of energy needed while resting in a temperate environment when the digestive system is inactive. It is the equivalent of figuring out how much gas an idle car consumes while parked. In such a state, energy will be used only to maintain vital organs, which include the heart, brain, kidneys, nervous system, intestines, liver, lungs, sex organs, muscles, and skin. Basal metabolism is usually the largest component of a person's total caloric needs. The daily caloric need is the BMR value multiplied by a factor with a value between 1.2 and 1.9, depending on activity level. Of the many BMR equations, the Mifflin-St Jeor Equation is considered the most accurate equation for calculating BMR. Mifflin-St Jeor Equation:For males: BMR = 10W + 6.25H - 5A + 5 For females: BMR = 10W + 6.25H - 5A - 161 where: W is body weight in kg His body height in cm Ais age In this assignment, you will write Python functions to help track how many calories a person consumes and determine how much weight they gain or lose over a certain time-period by using the BMR formulas listed above. There are several functions that you will write.
Suggested Coding ProcedureStep 1: Get input from user •Your main program should gather the following fivepieces of personal information from the individual using the code. Get their weightin pounds, heightin inches, agein years, a rating of their activitylevel (LOW, HIGH) and gender(male, female, etc.). Keep in mind you will need to create variable names for each of these items. oNote about gender: It is OK, for the purpose of this assignment, to give the user only two choices for gender (M, F). To be more sensitive and inclusive you may phrase your gender question: "Please share your gender identity so we can correctly calculate your BMI accurately. Enter 1 for male, 2 for female, 3 for other or 'I prefer not to say.”oIf the user entered the third option (not male or female), you will need a conditional statement here that informs the user that you can not do BMR calculations based on this answer:if gender == 3: print (“Calculations could not be completed.”)else: your program code to complete calls to functions and calculate required results goes here. Step 2: Conversions-write two convert functionsThe BMR formula uses kg (not pounds) and cm (not inches).•Write a function that has one numeric parameter (pounds)oTo convert lbs to kg: 1 lb = 0.453592 kgoThe function should return the number of kg calculated by this formula.•Write a function that has one numeric parameter (inches)oto convert inches to cm: 1 in = 2.54 cmoThe function should return the number of cm calculated by this formula.•Temporarily add print statements to ensure that your functions work as intended.oUser inputs valueoFunction to convert is called.oTemporary print statement prints the result returned by function.oUse the following tables to check your function calculations. The table shows 3 decimal places. Your code may result in more decimal places. That’s OK.oAfter you are sure these functions work, delete the temporary print statements.lbskg10045.35912556.699150.568.265232.2105.324Inchescm65.5166.3760152.472182.8873.1185.674
Step 3: Calculating BMR•Write a function to compute BMR based on the Mifflin-St Jeor Equation. This function will have fiveparameters: weight, height, age, gender, and activity level.Recall: For males: BMR = 10W + 6.25H - 5A + 5 For females: BMR = 10W + 6.25H - 5A - 161 where: W is body weight in kgH is body height in cmA is age •You will need a conditional statement (IF) that will compute BMR based on gender identity.•After that calculation, you will consider Activity Level. To simply our situation, multiply by 1.4for people with a low activity level and 1.8for those with a high activity level. •Return the final BMR value.•Call this function from your main program. Print the result. Test your program with the following input. Output below shows only 2 decimal places.Weight(pounds) Height(inches) Age Gender Activity Level BMR 120 64 45 Female High 2113.76 200 73 54 Male Low 2521.48 150 68 37 Prefer not to say High Calculations cannot be completed Now we will consider the calories you consume in a given number of days and how that affects your weight change. Step 4: Calories consumed •After you calculate the BMR, ask the user for the number of days they will input data for. •Write a function to compute the total calories based on that number of days. This function will have one integer parameter (number of days). •You will have a FOR loop for that number of days. For each day, ask how many calories the person consumes for each of three meals [breakfast, lunch and dinner].•Total the calories.•Return the total calories consumed.•Call this function from your main program.•Print the total number of calories consumed.Now we will calculate how many pounds the person’s weight changed (increased or decreased) during that time period. One piece of useful information to know is every 3500 calories is equal to one pound. To do this, you need to look at the difference between how many calories a person consumed and how many they needed to maintain their weight during those five days (remember you previously calculated the BMR). Here is an example:
Let’s say the person’s BMR is 2000 calories a day, and over 5 days they consumed a total of 17000 calories. We know 10000 calories (5*2000) would have maintained their weight. But they ate 7000 more than that (17000-10000), which is a gain of 2 pounds (7000/3500)!Step 5: Weight change •Write f unction that will calculate the change in body weight. This function will have THREE numeric parameters: bmr, total calories consumed, number of days. oCalculate bmr for the given number of days. oFind the difference between total calories consumed and the total bmr calories oDetermine the total lbs (divide by 3500) equivalent. ▪Note: to round your final lbs value to the nearest 100th:lbs = math.floor(lbs * 100) lbs = lbs/100 oReturn that value. Sample Runs:
CS110 – Principles of Computer ScienceAssignment #9 (Python Functions) Self-Check: 20 pointsDirections: Use the checklist below to review your work before submitting for evaluation by your TA: Read the problem description above to be sure you understand the program specifications. Check the list below to make sure you satisfied the program requirements.(2 point) function to convert inches to cm.(2 point) function to convert pounds to kilograms.Function to calculate BMRo(1 point) correct function header and returno(1 point) Correct calculations for maleso(1 point) Correct calculation for femaleso(1 point) Correct calculation for HIGH activity levelo(1 point) Correct calculation for LOW activity levelFunction to calculate total calories.o(1 point) correct function header and returno(1 point) correct loop for #dayso(1 point) Correct accumulation and initializationFunction to calculate weight change.o(1 point) correct function header and returno(2 points) correct calculationsMain Programo(1 point) Get necessary user inputo(2 points) Correct calls to functions(2 points) Program is well written and easy to read (good variable and function names)