Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 122: 4.6

Answer

Code

Work Step by Step

# (Health application: BMI ) Revise Listing 4.6, ComputeBMI.py, to let users enter # their weight in pounds and their height in feet and inches. For example, if a person # is 5 feet and 10 inches, you will enter 5 for feet and 10 for inches. KILOGRAMS_PER_POUND = 0.45359237 METERS_PER_INCH = 0.0254 weight = eval(input("Enter weight in pounds: ")) feet = eval(input("Enter feet: ")) inches = eval(input("Enter inches: ")) weightInKilograms = weight * KILOGRAMS_PER_POUND totalHeightInches = feet * 12 + inches heightInMeters = totalHeightInches * METERS_PER_INCH bmi = weightInKilograms / (heightInMeters * heightInMeters) print("BMI is", bmi) if bmi < 18.5: print("Underweight") elif bmi < 25: print("Normal") elif bmi < 30: print("Overweight") else: print("Obese")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.