PYTON 3 HELP!!!!! Doctors calculate and use your body mass index, or BMI, for me
ID: 3840788 • Letter: P
Question
PYTON 3 HELP!!!!!
Doctors calculate and use your body mass index, or BMI, for measuring your quality of health in terms of your weight or height. The formula for calculating one's BMI is: bmi = weight_kg/(height_m)^2 where weight is given in kilograms (kg) and height is given in metres (m). Write a Python function named bmi which takes weight and height parameters and returns the corresponding BMI. Include an appropriate docstring which states the function's purpose, parameter(s), and return value(s).The code from question 1 contains an example of a docstring. Also write a main program that reads the user's weight and height from the console, passes the entered values to the bmi function to perform the computation, obtains the function's return value, and then prints a message to the console that reports the user's BMI. Sample Run Here is an example of how your program's console output might look. Green text was entered by the user; blue text came from data returned by the bmi function. Please enter your weight (kg): 100 Please enter your height (m): 1.7 Your BHI is: 34.602076124567475Explanation / Answer
""" bmi = weight(kg)/height(m)2 """
def bmiCalculator(weight, height):
bmi = (weight)/ (height * height) # formula to calculate BMI
return format(bmi, '.17g') #pinting the result upto 17 significant digits
if __name__ == '__main__':
weight = float(raw_input("Please enter your weight (kg): ")) # parse input string to float and store in weight variable
height = float(raw_input("Please enter your height (m): ")) # parse input string to float and store in height variable
print ("Your BMI is: " + str(bmiCalculator(weight, height)) ) # print the result from the function. since the function returns float convert to string by using str
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.