zoukankan      html  css  js  c++  java
  • 中秋前的题目

    menu={
        'BeiJing':{
            'HaiDing':{
                'WuDaoKou':{
                    'sohu':{},
                    'netease':{},
                    'google':{}
                },
                'ZhongGuanCun':{
                  'IQiYi':{},
                  'CarHome':{},
                  'YouKu':{}
                },
                'ShangDi':{
                    'BaiDu':{}
                }
            },
            'ChangPing':{
                'ShaHe':{
                    'LaoNanHai':{},
                    'BeiHang':{}
                },
                'TianTongYuan':{},
                'HuiLongGuan':{}
            },
            'ChaoYang':{},
            'DongCheng':{}
        },
        'ShangHai':{
            'MinXing':{
                'People Square':{
                    'Fried Chiken Shop':{}
                }
            },
            'ZhaBei':{
                'Train Station':{
                    'XieCheng':{}
                }
            },
            'PuDong':{}
        },
        'ShanDong':{}
    }
    tag=True
    while tag:
        menu1=menu
        for key in menu1:
            print(key)
        choice1=input('第一层>>:').strip()
        if choice1=='b':
            break
        if choice1=='q':
            tag=False
            continue
        if choice1 not in menu1:
            continue
    
        while tag:
            menu_2=menu1[choice1]
            for key in menu_2:
                print(key)
    
            choice2=menu1[choice1]
            for key in menu_2:
                print(key)
    
            choice1=input('第二层>>:').strip()
    
            if choice1=='b':
                break
            if choice1=='q':
                tag=False
                continue
            if choice1 not in menu1:
                continue
    
            while tag:
                menu_2=menu1[choice1]
                for key in menu_2:
                    print(key)
    
                choice2=input('第二层>>:').strip()
    
                if choice2=='b':
                    break
                if choice2=='q':
                    tag=False
                    continue
                if choice2 not in menu_2:
                    continue
                while tag:
                    menu_3=menu_2[choice2]
                    for key in menu_3:
                        print(key)
                    choice3=input('第三层>>:').strip()
                    if choice3=='b':
                        break
                    if choice3=='q':
                        tag=False
                        continue
                    if choice3 not in menu_3:
                        continue
                    while tag:
                         menu_4=menu_3[choice3]
                         for key in menu_4:
                             print(key)
                         choice4=input('第四层>>:').strip()
                         if choice4=='b':
                             break
                         if choice4=='q':
                             tag=False
                             continue
                         if choice4 not in menu_4:
                             continue
    
    age = 18  
    count = 0  
    prize_dict = {0: 'doll', 1: 'transfomers', 2: 'ultraman', 3: '《Python从入门到放弃》'}
    
    
    while count < 3:
        inp_age = input('请输入你的年龄>>>')  # 与用户交互
    
       
        if not inp_age.isdigit():
            print('idot')
            continue
    
        inp_age_int = int(inp_age)
    
    
        if inp_age_int == age:
            print('猜对了')
    
            print(prize_dict)  
    
          
            for i in range(2):
                prize_choice = input(
                    '请输入你想要的奖品,如果不想要,则输入"n"退出!!!')  
    
            
                if prize_choice != 'n':
                    print(f'恭喜你获得奖品: {prize_dict[int(prize_choice)]}')
                else:
                    break
            break
    
        elif inp_age_int < age:
            print('猜小了')
    
        else:
            print('猜大了')
    
        count += 1  
    
        if count != 3:
            continue
    
        again_choice = input('是否继续游戏,继续请输入"Y",否则任意键直接退出.')  # 交互是否再一次
    
      
        if again_choice == 'Y':
            count = 0
    
  • 相关阅读:
    HDU 2089 不要62
    HDU 5038 Grade(分级)
    FZU 2105 Digits Count(位数计算)
    FZU 2218 Simple String Problem(简单字符串问题)
    FZU 2221 RunningMan(跑男)
    FZU 2216 The Longest Straight(最长直道)
    FZU 2212 Super Mobile Charger(超级充电宝)
    FZU 2219 StarCraft(星际争霸)
    FZU 2213 Common Tangents(公切线)
    FZU 2215 Simple Polynomial Problem(简单多项式问题)
  • 原文地址:https://www.cnblogs.com/jimGraymane/p/11514966.html
Copyright © 2011-2022 走看看