python循环选择练习

1、从键盘输入3个数,求最大值

a = int (input("第一个数:"))
b = int (input("第二个数:"))
c = int (input("第三个数:"))
if a > b:
    max = a
else:
    max = b
    if max > c:
        print("最大值:",max)
    else:
        print("最大值:",c)

2、买彩票,如果体彩中了500万,我买车、资助希望工程、去欧洲旅游,否则我买下一期体彩,继续烧高香。写程序描述。

lottery = 'y'
lottery = input('是否中500万大奖:y是/n否\n')
while lottery=='y':
    print('买车、资助希望工程、去欧洲旅游')
    break
else:
    print('购买下一次彩票,继续烧香')

3、会员购物时,根据积分的不同享受不同的折扣。计算会员购物时获得的折扣。
小于2000打9折,2000-4000打8折,4000-8000打7折,大于8000打6折

integral = int(input('请输入您的积分:'))
price = int(input('您的购物金额:'))
if integral < 2000:
    price = price * 0.9
elif integral < 4000:
    price = price * 0.8
elif integral < 8000:
    price = price * 0.7
else:
    price = price * 0.6
    print(f'您实际应付金额:{price}')

4、菜单功能
欢迎进入xxx系统
1登录
2注册
3退出
请选择:1
登录

print ('欢饮进入大数据系统')
state = int(input('请输入选项:'))
if state == 1:
    print ('登录')
elif state == 2:
    print ('注册')
else:
    print('退出')

5、机票的价格受季节旺季、淡季的影响,头等舱和经济舱价格也不同。假设机票原价5000元,请根据出行的月份和选择的仓位输出实际的机票价格。
旺季(4-10月) 头等舱 九折
经济舱 八折
淡季 头等舱 五折
经济舱 四折

控制台输出如下:
请输入您出行的月份:1-12
5
请选择头等舱(1)还是经济舱(2)?
2
您的机票价格为:3000.0


month = int(input('请输入您出行的月份:1-12\n'))
cabin = int(input('请选择头等舱(1)还是经济舱(2)?\n'))
price = 5000
if 4 <= month <= 10:
    if cabin == 1:
        price = price * 0.9
    else:
        price = price * 0.8
else:
    if cabin == 1:
        price = price * 0.5
    else:
        price = price * 0.4
print(f'您的机票价格为:{price}')


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值