
自己书写的源码:
from random import randint
def guess():
a = randint(1,100)
b=int(input("I'm thinking of a number! Try to guess the number I'm thinking of:"))
while True:
if a == b:
again=input('That"s it! Would you like to play again?(yes/no)')
break
elif a>b:
b = int(input('Too low! Guess again:'))
else:
b = int(input('Too Hign! Guess again:'))
if again == 'no':
print('Thanks for playing')
elif again == 'yes':
guess()
guess()


本文介绍了一个使用Python编写的简单猜数字游戏。游戏通过随机生成一个1到100之间的整数,玩家尝试猜测这个数字。如果猜错,游戏会提示玩家猜的数字是太高还是太低,并允许玩家再次猜测,直到猜中为止。游戏还提供了重新开始的选项。
7719

被折叠的 条评论
为什么被折叠?



