Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python The objectives of this lab are: - to show how functions canmake programs easier to write adudunderstand - to gain understanding of how to
python
The objectives of this lab are: - to show how functions canmake programs easier to write adudunderstand - to gain understanding of how to use functions someone else has written - to gain understanding of function arguments - to gain understanding of function return values Description You will create a program to compute the Basic Metabolic Rate of a person, which is the amount of calories your body needs each day to sustain its basic vital functions. This is similar to your project, but this time, we have provided a functionthat will calculate the BMR basedon a persoris age, sex, height, and weight. So all your program needs to do is prompt the user for their age, sex, weight in pounds, and height in inches, then call the function with those arguments. The furmion will retum the BMR, so you can then print out the message of the person's BMR. Your program will prompt the user for weight in pounds, height in inches, age in years, sex as m or f, in that order. You may use whatever prompts you want and feel are appropriate. Then, once you have all of the information, you need to call the function called conputeamR. The arguments that need to be sent to the function are the age, sex, height, and weight, in that order You can assume that all of the numeric inputs are integers, that is; no fractional or decimal parts. The function ComputeBMR is included as an external file to the zytab, but you do not need to be able tosee it or its code in order to use the function. You can treat the function as a black box that you send the proper arguments to, and it will return the proper value to you. You need to tell Python that you are using a function from an external file, similar to how you need to tell it when you are using a function from numeric inputs are integers, that is, no fractional or decimal parts The function ComputeBMR is included as an external file to the zyLab, but you do not need to be able to see it or its code in order to use the. function, You can treat the function as a black box that you send the proper arguments to, and it will return the proper value to you. You need to tell Python that you are using a function from an external file, similar to how you need to tell it when you are using a function from the math or random libraries. You will need to include the following line at the beginning of your program: Irom BMarunction import ComputeBMR This is telling Python that you are going to be using the function conputeBMr which can be found in the Python file BMRFunction. When you import a function this way, you do not need to do anything special to indicate where it came from, just call the function as if it exists as part of Python. For example, ComgateBMR(25, ' f ', 62,130) would call the function with age 25 . female, height of 62 inches, and weight of 130 pounds Once you receive the value back from the function; you need to print out a messege similar to the following (depending on the inputs): At 68 inches tall and weighing 155 pounds, at your age you need 1542.92 calories per day. At 63 inches tal1 and weighing 140 pounds, at your age you need 1384,48 calories per day. AMA should be printed to 2 decimal places, even though the function may be returning a float value with more or less than 2 decimal placer. NOTE You do not need to handle any error checking. That is done within the function. One of the test cases illustrates this but you do not need to do amything in your code to handle errors Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started