代码拉取完成,页面将自动刷新
#1.0版本
# import random
# num = random.randint(1,6)
# answer_num = int(input("请输入你的答案:"))
#
# while answer_num!=num:
# if answer_num>num:
# print("猜大了")
# else:
# print("猜小了")
# answer_num = int(input("请输入你的答案:"))
#
# print("恭喜你答对了,幸运数字为%d"%answer_num)
#2.0版本
# import random
# money = 5000
# num = random.randint(1,6)
# answer_num = int(input("请输入你的答案:"))
#
# while answer_num!=num and money>0:
# if answer_num>num:
# money -=500
# print("猜大了")
# else:
# money -=500
# print("猜小了")
# answer_num = int(input("请输入你的答案:"))
# money +=3000
# print("恭喜你答对了,幸运数字为%d"%answer_num)
# print("金币余额为:%d"%money)
#3.0版本
import random
answer = random.randint(1, 6)
while True:
user_answer = int(input('请输入一个数字:'))
if user_answer < answer:
print('猜小了')
elif user_answer > answer:
print('猜大了')
else:
print('恭喜你答对了', answer)
select = input('是否继续玩(Y或y表示继续,N或n 表示退出)')
if select in {'Y', 'y'}:
pass
else:
print('游戏结束!')
break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。