Repository navigation
Expand file tree
/
Copy pathBody_Mass_Index
More file actions
39 lines (30 loc) · 1.4 KB
/
Copy pathBody_Mass_Index
File metadata and controls
39 lines (30 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Body Mass Index
#Chapter 3. Lab #2
#3. Body Mass Index (page 185)
#Write a program that calculates and displays a person’s body mass index (BMI).
#The BMI is often used to determine whether a person with a sedentary lifestyle
#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.
#The program should display a message indicating whether the person has optimal weight,
#is underweight, or is overweight. A sedentary person’s weight is considered optimal if
#his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is
#considered underweight. If the BMI value is greater than 25, the person is considered overweight.
height = 0
weight = 0
height = float(input("Please enter your height: \n"))
if height > 0:
weight = float(input("Please enter your weight: \n"))
BMI=float((weight * 703) / (height**2))
if weight > 0:
print("BMI = ", "{:.2f}".format(BMI),sep='')
if BMI < 18:
print("You are underweight.",sep='')
elif BMI > 25:
print("You are overweight.",sep='')
else:
print("You are optimal.",sep='')
else:
print("That's an invalid weight.")
else:
print("That's an invalid height.")