2018-12-30 简单猜数游戏
作者:
化石0305 | 来源:发表于
2018-12-30 00:18 被阅读0次
import random
# 产生1-10的随机函数
A = random.randint(1, 10)
print(A)
while True:
# 定义变量
temp = input('不妨猜一下小甲鱼现在心里想的是哪个数字[退出:q]:')
# 将变量转为整数类型
if temp.isdigit():
guess = int(temp)
if (guess == A):
print('你是小甲鱼心里的蛔虫吗?!')
print('哼,猜中了也没奖励!')
break
elif guess > A:
print('太大啦!!')
elif guess < A:
print("太小啦!")
elif temp == "q":
print('游戏结束,不玩啦^_^')
break
else:
print("您的输入不正确,请重新输入!")
本文标题:2018-12-30 简单猜数游戏
本文链接:https://www.haomeiwen.com/subject/rrpmlqtx.html
网友评论