Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help Overview Be able to use functions that other people have written. Objectives The objectives of this lab are: - to show how functions can

image text in transcribedhelp

Overview Be able to use functions that other people have written. Objectives The objectives of this lab are: - to show how functions can make programs easier to write and understand - 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 function that will calculate the BMR based on a person's 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 function will return 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 computeBmR. 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 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: from BMRFunction import computeBMR This is telling Python that you are going to be using the function ComputeBMR 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, ComputebMr 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 message 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. Or, At 63 inches tall and weighing 140 pounds, at your age you need 1384.48 calories per day. BMR should be printed to 2 decimal places, even though the function may be returning a float value with more or less than 2 decimal places. 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 anything in your code to handle errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

=+ How well do you think you could do your job?

Answered: 1 week ago