第二章作业
03运行超市抹零结账行为
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)
money_real_str=str(money_real)
print("实收金额为:"+money_real_str)
print("学号后四位3124")

04计算学生成绩的分差和平均分
python = 95
english = 92
c = 89
sub = python - c
avg = (python + english + c) / 3
print("Pyhon课程和C语言课程的分数之差:"+ str(sub) + "分\n")
print("3门课的平均分: "+str(avg)+"分")
print("3124")

05 使用比较字符串的比较大小关系
代码如下:
05 使用比较运算符比较大小关系
python = 95
english = 92
c = 89
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 >= english的结果:"+ str(python>=english))
print("3124")

06手机店打折活动
print("手机店打折活动正在进行中~")
week = input("请输入今天星期(如:星期一):")
time = int(input("请输入当前整点时间(0~23):"))
if (week == "星期二" and (time >= 10 and time <= 15) ) or (week == "星期五" and (time >= 16 and time <= 20) ):
print("恭喜中奖啦!快来参与打折活动吧!")
else:
print("很遗憾没有中奖,请期待下次活动。")
print("3124")

存一个文件
file = open('D:\\新建文件夹.txt', 'w')
file.write("2.6.2")
file.close()
print("3124")

浙公网安备 33010602011771号