|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
times = 3
secret = random.randint(1,10)
print('------------------我爱鱼C工作室------------------')
guess = 0
print("不妨猜一下小甲鱼现在心里想的是哪个数字:", end=" ")
temp = input()
while temp.isdigit() is not True:
print("抱歉,输入不合法,", end='')
temp = input("请输入一个整数:")
while (guess != secret) and (times > 0) and (temp.isdigit() is True):
temp = input()
guess = int(temp)
times = times - 1
if guess == secret:
print("我草,你是小甲鱼心里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
else:
if guess > secret:
print("哥,大了大了~~~")
else:
print("嘿,小了,小了~~~")
if times > 0:
print("再试一次吧:", end=" ")
else:
print("机会用光咯T_T")
print("游戏结束,不玩啦^_^")
效果图如下:
效果图
如果有我理解错误的还请指出。代码在下方:
- import random
- times = 3
- secret = random.randint(1,10)
- print('------------------我爱鱼C工作室------------------')
- guess = 0
- # print("不妨猜一下小甲鱼现在心里想的是哪个数字:", end=" ")
- # print(secret)
- temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:\n")
- while temp.isdigit() is not True:
- # print("抱歉,输入不合法,", end='')
- temp = input("抱歉,输入不合法,请输入一个整数:")
- while (guess != secret) and (times != 0) and (temp.isdigit() is True):
- times = times - 1
- # temp = input()
- guess = int(temp)
- if guess == secret:
- print("我草,你是小甲鱼心里的蛔虫吗?!")
- print("哼,猜中了也没有奖励!")
- elif guess > secret:
- print("哥,大了大了~~~")
- temp = input("再试一次吧!:")
- else:
- print("嘿,小了,小了~~~")
- temp = input("再试一次吧!:")
- print("没机会啦~~游戏结束,不玩啦^_^")
复制代码
|
|