[輸入樣例] 60,1.6 [輸出樣例]
Your BMI is 23.4 normal
[提示]
程式中體重和身高的輸入可用“weight, height = eval(input())”語句表示。
def exercise1():
weight, height = eval(input('Please input your weight and height:'))
bmi = weight / (height ** 2)
if bmi < 18.5:
print('Your BMI is {:.1f} {}'.format(bmi, 'too thin'))
elif bmi < 24:
print('Your BMI is {:.1f} {}'.format(bmi, 'normal'))
elif bmi < 28:
print('Your BMI is {:.1f} {}'.format(bmi, 'overweight'))
else:
print('Your BMI is {:.1f} {}'.format(bmi, 'fat'))
```
2. 按公式:C= 5/9×(F-32) ,將華氏溫度轉換成攝氏溫度,並產生一張華氏 0~300 度與
對應的攝氏溫度之間的對照表(每隔 20 度輸出一次)
def exercise2():
for i in range(0, 301, 20):
c = 5 / 9 * (i - 32)
print('{:d}華氏度:{:.0f}攝氏度'.format(i, c))
```