SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Simple Functions
Exercise:
Programming Exercises
Question:6 | ISBN:9780132576376 | Edition: 2

Question

Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:

BMI = weight x 703 / height^2

where weight is measured in pounds and height is measured in inches.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Python program code:

#The method 'computeBMI' is used to 
#calculate a person’s body mass index (BMI)
def computeBMI(weight, height):
    bmi = weight * 703 / (height ** 2)
    return bmi
#main method
def main():
    #Prompt and read the weight and height in pounds
    weight = float(input("Enter weight in pounds: "))
    height = float(input("Enter height in inches: "))
    #Call the method and display output
    BMI = computeBMI(weight, height)
    print("BMI:", format(BMI, ".2f"))
if __name__ == "__main__":
    main()

Executed Output:

Enter weight in pounds: 200
Enter height in inches: 13
BMI: 831.95

 

0 0

Discussions

Post the discussion to improve the above solution.