-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMI Calculator.py
47 lines (30 loc) · 1.18 KB
/
BMI Calculator.py
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
39
40
41
42
43
44
45
46
47
def user_mass():
user_weight = float(input('Enter your weight: '))
weight_unit = input('Is the weight entered in Pounds or Kg?(Enter (P) or (Kg)): ')
if weight_unit.lower() == 'p':
weight = user_weight * 0.4535
elif weight_unit.lower() == 'kg':
weight = user_weight
return weight
def user_height():
height_choice = input('Do you want to enter your height in (Feet, Inches (F)) or (cm (c)): ')
if height_choice.lower() == 'f':
feet = int(input('Enter the "feet" component: '))
inch = int(input('Enter the "inch" component: '))
height = (feet * 30.48) + (inch * 2.54)
elif height_choice.lower() == 'c':
height = float(input('Enter height: '))
height_in_m = height/100
return height_in_m
try:
bmi = (user_mass()/((user_height())**2))
if bmi <= 16:
print('Severly Underweight')
elif bmi <= 18.5:
print('Underweight')
elif bmi <= 25:
print('Healthy')
elif bmi <= 30:
print("Overweight")
except ZeroDivisionError:
print('Division By Zero is not Possible.\nEnter the correct height')