Skip to content

Commit 697d573

Browse files
committed
通过使用if else语句,通过输入的身高体重计算bmi
1 parent d1ca89e commit 697d573

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Base/Samples/BMI.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
print('输入身高')
4+
height = input()
5+
height = float(height)
6+
print('输入体重')
7+
weight = input()
8+
weight = float(weight)
9+
bmi = (weight/height**2) #**2表示2次方 如果为3则为3次方
10+
if bmi<18.5:
11+
print('过轻')
12+
elif 18.5<=bmi<25:
13+
print('正常')
14+
elif 25<=bmi<28:
15+
print('过重')
16+
elif 28<=bmi<32:
17+
print('肥胖')
18+
elif bmi>=32:
19+
print('严重肥胖')

0 commit comments

Comments
 (0)