PYTHON笔记第二章之输入输出

输入输出 判段语句

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!"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值