Chapter 2

'''Chapter 2_bmi_test'''1

height = 1.70
print("您的身高:"+str(height))
weight = 48.5
print("您的体重:"+str(weight))
bmi=(weight/height*height)
print("您的BMI指数为:"+str(bmi))
if bmi<18.5:
print("您的体重过轻 QAQ")
if bmi>=18.5 and bmi<=24.9:
print("正常范围,请继续保持 😃")
if bmi>=24.9:
print("您的体重过重,请立即减肥 😦")

'''Chapter 2_camparison'''2

python=95
english=92
c_program=89
print("python=" +str(python))
print("c program="+ str(c_program))
print("english="+ str(english))
print("python<english --result:"+ str(python<english))
print("python>english --result:"+ str(python>english))
print("python==english --result:"+ str(python == english))
print("python!=english --result:"+ str(python!=english))
print("python<=english --result:"+ str(python<=english))
print("python>=english --result:"+ str(python>=english))

'''Chapter 2_erase_zero'''3

money_all = 56.75 + 72.91 + 88.50 + 26.37 + 68.51
money_all_str = str(money_all)
print("商品总金额为:"+ money_all_str)
money_real=int(money_all)
print("实收金额为:" + str(money_real))

'''Chapter 2_score_handle'''4

python=95
english=92
c_program=89
sub=python-c_program
avg=(python+english+c_program)/3
print("python与c语言分数之差为:"+str(sub))
print("平均分为:"+ str(avg))

'''Chapter 2_tank_print'''5

image

'''Chapter 2_sale'''6

print("\nPhone is on sale, get your own discount!")
strWeek=input("What date is it today? ")
intTime=int(input("Range(0~23)"))
if(strWeek == "Tuesday" and (intTime >= 10 and intTime <= 11)) or (strWeek == "Tuesday" and (intTime >= 14 and intTime <= 15)):
print("congratulations ! you get -20% off ")
else:
print("thanks for your participation.")
image

'''Chapter 2_bmi_test_improved'''

height=float(input("请输入您的身高"))
weight=float(input("请输入您的体重"))
bmi=weight/(height*height)
print("您的BMI指数为:"+str(bmi))
if bmi<18.5:
print("您的体重过轻 QAQ")
if bmi>=18.5 and bmi<=24.9:
print("正常范围,请继续保持 😃")
if bmi>=24.9:
print("您的体重过重,请立即减肥 😦")
image

project

print("欢迎使用移动有限公司充值业务,请输入充值金额:")
money=int(input("输入数值:"))
print("充值成功,您本次充值:",money)

faheight=float(input("请输入父亲的身高(单位为米)😊)
maheight=float(input("请输入母亲的身高(单位为米)😊)
sonheight=(faheight+maheight)*0.54
print("预测儿子身高为:"+str(sonheight))

posted @ 2022-09-14 16:12  Kyaria  阅读(25)  评论(0编辑  收藏  举报