Python 官方文档:入门教程 => 点击学习
def guessnum(): guess,count=0,1 rand=random.randint(1,101) print ('you just have five time') guess=int(input('please
def guessnum():
guess,count=0,1
rand=random.randint(1,101)
print ('you just have five time')
guess=int(input('please enter your guess num:'))
while True:
if guess > rand:
print('too large')
elif guess < rand:
print('too small')
elif guess == rand:
print ('you are so lucky ')
break
count=count+1
print ('you just have '+str(5-count+1)+' times')
guess=int(input('please enter your num again:'))
if count == 5:
print ('sorry,your are lose,the secret num is '+str(rand))
break
--结束END--
本文标题: Python猜数字游戏
本文链接: https://lsjlt.com/news/182767.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0