输入输出 判段语句
nat=input("please input the Chinese score:") #输出提示语并获取字符串
math=input("please input the math socre:") #输出提示语并获取字符串
eng=input("please input the English score:") #输出提示语并获取字符串
sum=int(nat)+int(math)+int(eng) #获取到的串转换为数字并求和
average=sum/3 #求均值
print("the sum: %d, average : %5.2f" %(sum,average)) #输出
pw=input("please input the code:") #输出提示语并获取字符串
if(pw==("1234")): #如果值为"1234"
print("welcome!") #输出"welcome!"
money=int(input("please input the shopping accout:"))#输出提示语并获取字符串
if(money>=10000): #如果输入值大于10000
if(money>=100000): #大于1E5
print(str(money*0.8),end=" yuan \n") #输出八折价
elif(money>=50000): #大于5E4
print(str(money*0.85),end=" yuan \n") #输出八五折价
elif(money>=30000): #大于3E4
print(str(money*0.9),end=" yuan \n") #输出九折价
else: #否则,在一万到三万间
print(str(money*0.95),end=" yuan \n") #输出九五折价
else: #否则,小于一万
print(str(money),end=" yuan \n") #原额输出
print("姓名 座号 语文 数学 英文 ")
print("%4s %2d %3d %3d %3d" %("林大明",1,100,87,79)) #注意输出格式
print("%4s %2d %3d %3d %3d" %("陈阿中",2,74,88,100)) #%3s字符串,占三个全角字符位,靠右
print("%4s %2d %3d %3d %3d" %("张小英",11,82,65,8)) #%3d整型,占三位,靠右,靠右
pw=input("please input the code:") #输出提示语并获取字符串
if(pw==("1234")): #如果值为"1234"
print("welcome!") #输出"welcome!"
else: #否则
print("wrong code!")#输出"wrong code!"