1 #03超市抹零 2 bill=float(input("请输入商品的总价格")) 3 print("{:.0f}".format(bill))
1 #04成绩分差和平均值 2 import math 3 4 grade1=int(input()) 5 grade2=int(input()) 6 grade3=int(input()) 7 gap1=abs(grade1-grade2) 8 gap2=abs(grade2-grade3) 9 gap3=abs(grade3-grade1) 10 print(f"gap1={gap1},gap2={gap2},gap3={gap3}") 11 def average(*args): 12 return sum(args, 0.0) / len(args) 13 14 avg=average(grade1,grade2,grade3) 15 print(f"avg={avg}")
1 #05比较运算符大小 2 num1=input() 3 num2=input() 4 print("num1<num2:"+str(num1<num2)) 5 print("num1>num2:"+str(num1>num2)) 6 print("num1==num2:"+str(num1==num2)) 7 print("num1!=num2:"+str(num1!=num2)) 8 print("num1<=num2:"+str(num1<=num2)) 9 print("num1>=num2:"+str(num1>=num2))
1 #06打折:星期五10:00到14:00打八折和星期六一整天打75折 2 Week=input("请输入星期几:") 3 Time=int(input("请输入你要去的时间")) 4 if Week =="星期五" and (10<=Time<=14): 5 print("八折") 6 elif Week == "星期六" and (0<=Time<=23): 7 print("七五折") 8 else: 9 print("不在打折时间内")
print("3142")
笔者:
3142
标签:chapter,num1,num2,读书笔记,int,grade1,print,input From: https://www.cnblogs.com/Calinio/p/17801647.html