#!/usr/bin/python3
#猜数字
import random
secretNumber=random.randint(1,20)
print('我想了一个1到20间的整数,你能猜出来吗?')
for guessesTaken in range(1,7):
print('猜一下!')
guess=int(input())
if guess<secretNumber:
print('太小了!')
elif guess>secretNumber:
print('太大了!')
else:
break
if guess==secretNumber:
print('对了,你第'+str(guessesTaken)+'次就猜对了正确答案!')
else:
print('只能猜6次哦,正确答案为'+str(secretNumber)+'!')
Python语言例题集(003)
于 2024-02-12 00:54:35 首次发布