import random
m = random.randint(1, 100)
total = 5
while total > 0:
n = int(input(‘一个1到100的整数:’))
if n > m:
print(‘大了’)
total -= 1
if total == 0:
print(f’答案是 {n} ‘)
else:
print(f’还有 {total} 次机会’)
elif n < m:
print(‘小了’)
total -= 1
if total == 0:
print(f’答案是 {n} ‘)
else:
print(f’还有 {total} 次机会’)
else:
print(f’猜对了,答案是 {n} ')
break
猜
最新推荐文章于 2024-03-16 15:50:03 发布