# if [condition]: # condition is ture, then run code1 and code2
# code1...
# code2... # four spaces indentation. can have only one code line, or more than one code lines
# else: # condition is false
# code3...
# code... # this code line is not a part of the if/else structure
# -----
# if [condition]:
# code...
# elif [condition]:
# code...
# elif [condition]:
# code...
# else:
# code...
# input will get str type
weight = input("pls input your weight(kg):")
height = input("pls input your height(m):")
bmi = float(weight) / (float(height) ** 2)
print("your BMI is " + str(bmi))
if bmi <= 18.5:
print("shou")
elif bmi <= 25:
print("normal")
elif bmi <= 30:
print("pang")
else:
print("pang+")
python入门 --- input + if/else
最新推荐文章于 2024-04-24 13:35:29 发布