ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

第2章

2022-09-14 12:31:25  阅读:251  来源: 互联网

标签: python money bmi str english print


example 1.bmi

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("您的体重过轻 ~@_@~")
if bmi>=18.5 and bmi<24.9:
print("正常范围,注意保持 (-_-)")
if bmi>=24.9 and bmi<29.9:
print("您的体重过重~@_@~")
if bmi>=29.9:
print("肥胖 ^@_@^")

 

 

 example 2.tank

print('''
                                                ▶ 学编程,你不是一个人在战斗~~
                                                |
                                   __\--__|_
II===========0000[/ ★007--_|
                         _____\_________|/-----.
                        /___sadadadadsad.com___|
                            \◎◎◎◎◎◎◎◎◎◎/
                          ~~~~~~~~~~~~~~~~~~~~
''')

 

 

 

 

 

example 3. erase_zero

money_all = 56.75+38.4+231.3+8.65
money_all_str=str(money_all)
print("商品总额为:" + money_all_str)
money_real = int(money_all)


money_real_str = str(money_real)
print("实收金额:" + money_real_str)

 

 

 

 example 4. score_handle

python = 95
english = 92
c = 89
sub=python-c
avg=(python + english + c) / 3
print("Python课程和c语言课程的分数之差:" + str(sub) + "分\n")
print("3门课的平均分:" + str(avg) + "分")

 

 

 

 example 5.comparison_operator

python = 95
english = 92
c = 89
#输出3个变量的值
print("python = "+str(python)+" english = "+str(english) + "c = "+str(c) + "\n")
print("python < english的结果:" +str(python < english))
print("python > english的结果:" +str(python > english))
print("python == english的结果:" +str(python == english))
print("python != english的结果:" +str(python != english))
print("python <= english的结果:" +str(python <= english))
print("python >= c的结果:" +str(python >= c))

 

 

 

 

 example 6.sale

print("\n手机店正在打折,活动进行中……")
strWeek = input("请输入中文星期(如星期一) :")
intTime =int (input("请输入时间中的小时(范围:0~23):"))
#判断是否满足活动参与条件(使用了if语句)
if(strWeek =="星期二" and (intTime>= 10 and intTime <=11)) or (strWeek == "星期五" and (intTime >= 14 and intTime <=15)):
print("恭喜你,获得了折扣活动参与资格。快快选购吧!")
else:
print("对不起,您来晚一步,期待下次活动")

 

 

 

 

example 7 improved_bmi

height = float (input("请输入您的身高(单位为米):"))
weight = float (input("请输入您的体重(单位为千克):"))
bmi= weight/(height*height)
print ("您的BMI指数为:"+str(bmi))
#判断身材是否合理
if bmi<18.5:
print("您的体重过轻 ~@_@~")
if bmi>=18.5 and bmi<24.9:
print("正常范围,注意保持 (-_-)")
if bmi>=24.9 and bmi<29.9:
print("您的体重过重~@_@~")
if bmi>=29.9:
print("肥胖 ^@_@^")

 

 

标签:,python,money,bmi,str,english,print
来源: https://www.cnblogs.com/sada1/p/16692615.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有