Python编程解决“今天午饭吃什么?”

import time
import random
food = ['鸡','鸭','鱼','肉','菜','蛋','面']
res = ['KFC','麦当劳','德克士','老娘舅','全聚德','达美乐']

def welcome():      #欢迎语
    print('欢迎使用“选择困难症助手”!')
    time.sleep(1)
    print('今天中午吃什么呢?\n1.随机食物\n2.随机餐厅\n3.自定义\n4.退出')

def print_choice(a):      #选择
    print('系统帮您选择了%s。您满意么?满意请输入1,不满意请输入2:'%a)

def end_choice(a):     #结束语
    print('您的选择是%s,感谢使用!'%a)

def get_res():      #取得餐厅列表
    res_reserve = []
    print('请输入您心仪的三家餐厅')
    for i in range(3):
        a = input('请输入第%s家餐厅'%(i+1))
        res_reserve.append(a)
    return(res_reserve)

welcome()
main_choice = int(input('请选择:'))
while main_choice == 1:
    food_try = random.choice(food)
    print_choice(food_try)
    a = int(input('请选择'))
    if a == 1:
        end_choice(food_try)
        break

while main_choice == 2:
    res_try = random.choice(res)
    print_choice(res_try)
    a = int(input('请选择'))
    if a == 1:
        end_choice(res_try)
        break

if main_choice == 3:
    res3 = get_res()
    while True:
        res_try = random.choice(res3)
        print_choice(res_try)
        a = int(input('请选择'))
        if a == 1:
            end_choice(res_try)
            break

elif main_choice == 4:
    end_choice('“结束”')

  • 28
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值