zoukankan      html  css  js  c++  java
  • Python学习3

    猜数游戏

    import random
    while True:
    first=random.randrange(100)
    while True:
    second=int(input('请猜'))
    if first>second:
    print('小了')
    elif first==second:
    print('对了')
    break
    else:
    print('大了')



    购物车

    flag = 'ok'
    lists = []
    goods_lists = [['水果',[['鸭梨',18],['桃子',30],['苹果',21],['榴莲',5],['香蕉',3]]],['蔬菜',[['胡萝卜',11],['香菜',21],['圆白菜',3],['土豆',2],['地瓜',4]]]]
    while True:
    if flag=='no':
    total_price = 0
    print('商品名称 单价 购买数量 购买总价')
    for a, b, c, d in lists:
    print(' ' + a, ' ' * 3 + str(b), ' ' * 3 + str(c), ' ' * 3 + str(d))
    total_price += d
    print('总价格为' + str(total_price))
    break
    n = 1
    print('欢迎光临 XXX超市')
    print('################################')
    for a,b in goods_lists:
    print(' '+str(n)+' '+a)
    n = n+1
    print('################################')
    num1 = int(input('请选择分类序号:')) - 1
    while True:
    m = 1
    print('欢迎光临 XXX超市')
    print('################################')
    for goods in goods_lists[num1][1]:
    print(' '+str(m)+' '+goods[0]+' '+str(goods[1])+'元')
    m = m + 1
    print('################################')
    num2 = int(input('请选择商品序号:'))-1
    if num2==-1:
    break
    if num2==-2:
    flag = 'no'
    break
    n_lists = []
    num3 = int(input('请选择购买数量(输入0返回上级菜单,输入-1结算退出)'))
    n_lists.append(goods_lists[num1][1][num2][0])
    n_lists.append(goods_lists[num1][1][num2][1])
    n_lists.append(num3)
    n_lists.append(goods_lists[num1][1][num2][1]*num3)
    lists.append(n_lists)


    我的


    flag = 'ok'
    lists = []
    goods_lists = [['水果', [['苹果', 5], ['葡萄', 10], ['草莓', 15], ['芒果', 8], ['橘子', 6]]]
    , ['蔬菜', [['胡萝卜', 2], ['土豆', 1], ['芹菜', 3], ['菠菜', 4], ['大葱', 1]]]]
    while True:
    if flag == 'no':
    total_price = 0
    print('商品名称 单价 数量 总价')
    for a, b, c, d in lists:
    print(' ' + a, ' ' * 3 + str(b), ' ' * 3 + str(c), ' ' * 3 + str(d))
    total_price += d
    print('总价为' + str(total_price))
    break

    n = 1
    print('欢迎光临55超市')
    print('########################')
    for a, b in goods_lists:
    print(' '+str(n)+' '+a)
    n = n + 1
    print('########################')

    num1 = int(str(input('请选择分类序号:'))) - 1
    while True:
    m = 1
    print('欢迎光临55超市')
    print('########################')
    for goods in goods_lists[num1][1]:
    print(' '+str(m)+' '+goods[0]+' '+str(goods[1])+'元')
    m = m + 1
    print('########################')
    num2 = int(str(input('请选择商品序号:'))) - 1
    if num2 == -1:
    break
    if num2 == -2:
    flag = 'no'
    break
    n_lists = []
    num3 = int(str(input('请选择购买数量(输入0返回上级菜单,输入-1结算退出)')))
    n_lists.append(goods_lists[num1][1][num2][0])
    n_lists.append(goods_lists[num1][1][num2][1])
    n_lists.append(num3)
    n_lists.append(goods_lists[num1][1][num2][1] * num3)
    lists.append(n_lists)


  • 相关阅读:
    利用BootStrap Table插件实现自己的弹出框分页。
    spring+redis的集成,使用spring-data-redis来集成
    Postgresql/Greenplum中将数字转换为字符串TO_CHAR函数前面会多出一个空格
    将根据时间戳增量数据方案修改为根据批次号增量数据方案
    Postgresql查询出换行符和回车符:
    增量数据,如果下次增量数据存在重复数据,如何解决。
    creating server tcp listening socket 127.0.0.1:6379: bind No error
    echarts的地图点击事件
    Postman 安装及使用入门教程(我主要使用接口测试)
    HTML5 canvas 捕鱼达人游戏
  • 原文地址:https://www.cnblogs.com/tangmf/p/14011115.html
Copyright © 2011-2022 走看看