Repository navigation
Expand file tree
/
Copy pathcalc_BMI.py
More file actions
53 lines (44 loc) · 1.46 KB
/
Copy pathcalc_BMI.py
File metadata and controls
53 lines (44 loc) · 1.46 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def input_data():
name = input('\nWhat\'s your name?\n')
age_s = input('\nAnd how old are you?\n')
height_s = input('\nPlease tell me your height. (In meters)\n')
weight_s = input('\nAnd now please tell me your weight. (In Kilograms)\n')
return name, age_s, height_s, weight_s
def calc_BMI(age_s, height_s, weight_s):
age = int(age_s)
height = float(height_s)
weight = float(weight_s)
BMI = weight/height**2
if BMI < 18.5:
tip_BMI = 'too thin'
elif BMI >= 18.5 and BMI < 25:
tip_BMI = 'normal'
elif BMI >= 25 and BMI < 28:
tip_BMI = 'a little over-weight'
elif BMI >= 28 and BMI < 32:
tip_BMI = 'fat'
else:
tip_BMI = 'too fat'
return BMI, age, tip_BMI
def output_age_BMI():
if age >= 18:
print('\nHello %s. You are an adult. \nAnd your BMI is %.2f. You are %s. \n' % (
name, BMI, tip_BMI))
elif age >= 7:
print('\nHello %s. You are a teenager. \nAnd your BMI is %.2f. You are %s. \n' % (
name, BMI, tip_BMI))
else:
print('\nHello %s. You are a child. \nAnd your BMI is %.2f. You are %s. \n' % (
name, BMI, tip_BMI))
choice = 1
while choice == 1:
choice = int(input(r'''
Please choose what you wanna do next:
1. Calculate your BMI.
2. Exit
'''))
if choice == 2:
break
name, age_s, height_s, weight_s = input_data()
BMI, age, tip_BMI = calc_BMI(age_s, height_s, weight_s)
output_age_BMI()