用Python写猜数字游戏
程序员文章站
2024-03-23 20:44:58
...
import random
target = random.randint(1,1000)
count = 0
while True:
guess = eval(input('请输入一个猜测的整数:'))
count = count + 1
if guess > target:
print('猜大了')
elif guess < target:
print('猜小了')
else:
print('猜对了')
break
print('此轮的猜测次数是:'.count)
上一篇: Shell编程--while循环
下一篇: xinixn -数据分析