zoukankan      html  css  js  c++  java
  • 购物小程序

     1 #!/usr/bin/env python
     2 # -*- coding:utf-8 -*-
     3 # Author:Er fei
     4 input_wage=input("请输入工资:")
     5 input_wage=input_wage.strip()
     6 if input_wage.isdigit():
     7     input_wage=int(input_wage)
     8     goods_list={"苹果4s":800,"苹果6s":5000,"苹果7":7000,"oppor9":5999}
     9     print("欢迎来到网络商城".center(50,"*"))
    10     print(goods_list)
    11     buy_list={}
    12     while True:
    13         already_bought=input("苹果4s:1,6s:2,7:3,oppor9:4请输入要购买的商品:")
    14         if already_bought=="1":
    15             goods=goods_list["苹果4s"]
    16             if goods_list["苹果4s"]<input_wage:
    17                 input_wage=input_wage-goods_list["苹果4s"]
    18                 print(input_wage)
    19                 buy_list["苹果4s"]=800
    20                 print(buy_list)
    21             else:
    22                 print("余额不足请充值或更换商品后重试!")
    23 
    24 
    25         elif already_bought=="2":
    26                 goods = goods_list["苹果6s"]
    27                 if goods_list["苹果6s"] < input_wage:
    28                     input_wage = input_wage - goods_list["苹果6s"]
    29                     print(input_wage)
    30                     buy_list["苹果6s"] = 5000
    31                     print(buy_list)
    32                 else:
    33                     print("余额不足请充值或更换商品后重试!")
    34         elif already_bought=="3":
    35                 goods = goods_list["苹果7"]
    36                 if goods_list["苹果7"] < input_wage:
    37                     input_wage = input_wage - goods_list["苹果7"]
    38                     print(input_wage)
    39                     buy_list["苹果7"] = 7000
    40                     print(buy_list)
    41                 else:
    42                     print("余额不足请充值或更换商品后重试!")
    43         elif already_bought=="4":
    44                 goods = goods_list["oppor9"]
    45                 if goods_list["苹果4s"] < input_wage:
    46                     input_wage = input_wage - goods_list["oppor9"]
    47                     print(input_wage)
    48                     buy_list["oppor9"] = 5999
    49                     print(buy_list)
    50                 else:
    51                     print("余额不足请充值或更换商品后重试!")
    52 else:
    53     print("输入不合法请重新输入工资!!!")

  • 相关阅读:
    Mysql中判断一个点是否落在多边形内
    Linux进阶之环境变量文件/etc/profile、/etc/bashrc、/etc/environment
    gitlab打开group_member页面500错误
    jenkins连接k8s集群
    svn备份迁移
    npm管理nodejs版本
    linux远程执行shell脚本或者python脚本无法获取远程主机的环境变量
    ansible-playbook对服务器安装阿里云日志服务agent--ilogtail
    linux安装Arachni进行web网站扫描
    nginx使用免费ssl证书
  • 原文地址:https://www.cnblogs.com/zang963469010/p/6132602.html
Copyright © 2011-2022 走看看