03运行超市抹零结账行为
money_all=67.99+11.75+21.1+8.49+25.89+17.5+22.4 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)
print("学号后四位3126")
运行结果
04计算学生成绩的分差和平均分
python=80
english=92
c=89
sub=abs(python-c)
avg=(python+english+c)/3
print("Python课程和C语言课程的分数之差:",sub,"分")
print("3门课的平均分:",avg ,"分")
print("学号后四位3126")
运行结果
05比较运算符比较大小关系
python = 80 english = 92 c = 89 print("python = " ,python,"\nenglish = " ,english," \nc = ",c,"\n") print("python<english的结果:",python<english) print("python>english的结果:",python>english) print("python==english的结果:",python==english) print("python!=english的结果:",python!=english) print("python<=english的结果:",python<=english) print("english>=c的结果:",python>=c) print("学号后四位3126")
运行结果
06手机店打折活动
print("手机店正在打折,活动进行中......") strWeek=input("请输入中文星期(如星期一):") intTime=int(input("请输入时间中的小时——范围:0~23:")) if(strWeek =="星期二"and(intTime >=10 and intTime <=11)) \ or (strWeek =="星期五" and(intTime >=14 and intTiwe <=15)): print("恭喜您,获得了折扣活动参与资格,快快选购吧!") else: print("对不起,您来晚一步,期待下次活动......") print("学号后四位3126")
运行结果
标签:real,读书笔记,Python,money,28,python,str,english,print From: https://www.cnblogs.com/FLETCHER-/p/17794767.html