欢迎来到抽奖游戏!

while True: print('请选择抽奖方式:') print('1. 抽取 1-10 的数字') print('2. 抽取 1-100 的数字') print('3. 抽取 1-1000 的数字') print('4. 退出游戏')

choice = input('请输入选项:')

if choice == '1':
    num = random.randint(1, 10)
    print('恭喜你,抽中了数字:', num)
elif choice == '2':
    num = random.randint(1, 100)
    print('恭喜你,抽中了数字:', num)
elif choice == '3':
    num = random.randint(1, 1000)
    print('恭喜你,抽中了数字:', num)
elif choice == '4':
    print('谢谢参与,再见!')
    break
else:
    print('输入错误,请重新选择。')
Python 抽奖小游戏 - 随机数生成器

原文地址: https://www.cveoy.top/t/topic/lLYX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录