zoukankan      html  css  js  c++  java
  • python shopping incomplete code

    #shopping code
    #shopping.py
    #导入登录模块
    import login
    # shop car beginning
    salary = input("请输入工资: ")
    ###判断输入工资是否为整型###
    if salary.isdigit():
    salary = int(salary)
    else:
    print ("salary not digit")
    exit()
    ###打印一句牛逼的话####
    welcome_msg = 'welcome to our shoping mall'
    print(welcome_msg.center(50, '-'))
    ###商品列表####
    shopcar = [
    ('Iphone', 5888),
    ('Mac Air', 8000),
    ('XiaoMi', 19.9),
    ('coffee', 30),
    ('Tesla', 8200),
    ('Bike', 700),
    ('Cloth', 200)
    ]
    for i in enumerate(shopcar):
    index = i[0]
    product = i[1][0]
    p_salary = i[1][1]

    print (index, product, p_salary)

    exit_msg = '你可以输入e或者q退出,啦啦啦'
    print(exit_msg.center(50, '-'))

    while True:
    num = input("33[5;30;43mplease print bianhao:33[0m ")
    if num.isdigit():
    num = int(num)
    ###判断输入编号不能大于7###
    if num > 7:
    print ("输入错误,没有此编号")
    continue
    ##输入编号购买商品###
    num = input("请输入商品编号: ")
    price = shopcar[num][1]
    price_p = shopcar[num][0]
    if salary > price:
    salary -= price
    print ("购买成功,余额为", salary)
    print ("购买的商品为:", price_p)
    else:
    print ("余额不足,请及时充值")
    print ("余额为", salary)
    continue
    ##exit shoping##
    elif num.isalpha():
    num = str(num)
    if num == 'e' or num == 'q':
    print ("余额为", salary)
    bye_msg = 'next to meet you,see you'
    print(bye_msg.center(50, '-'))
    break
    # if price_p():
    # print ("余额为", salary)
    # exit()
    # else:
    # print ("购买成功,余额为", salary)
    # print ("购买的商品为:", price_p)
    # bye_msg = 'next to meet you,see you'
    # print(bye_msg.center(50, '-'))
  • 相关阅读:
    contentSize、contentInset和contentOffset区别 分类: iphone开发
    iOS设计模式——Category
    如何更好地限制一个UITextField的输入长度
    UIApplication sharedApplication详细解释-IOS
    IOS --- 对象归档
    iOS 数据持久化之使用NSUserDefaults存储数据
    判断素数 一个数的约数 一个整数的幂次约分
    埃氏筛法
    双六(扩展欧几里得算法)
    矩阵快速幂 模板
  • 原文地址:https://www.cnblogs.com/alex-note/p/6836770.html
Copyright © 2011-2022 走看看