python基础练习:
 
一、猜年龄 , 可以让用户最多猜三次!
age=40
count = 1
while count <=3 :
user_guess=int(input("input your guess:"))
if (user_guess > age):
print("try small")
elif (user_guess < age):
print("try bigger")
else:
print("you got it!")
break
count+=1;
else:
print("笨蛋,你没有尝试了")

  

python基础练习-猜年龄、编写登陆接口小程序-LMLPHP

python基础练习-猜年龄、编写登陆接口小程序-LMLPHP

二、猜年龄 ,每隔3次,问他一下,还想不想继续玩,y,n
age=40
count = 0
while count >=0:
user_guess=int(input("input your guess:"))
if (user_guess > age):
print("try small")
elif (user_guess < age):
print("try bigger")
else:
print("you got it!")
break
count+=1;
if count%3==0:
y_or_n=input("do you want to try?(y or n):")
if y_or_n =="y":
continue
else:
break

  

python基础练习-猜年龄、编写登陆接口小程序-LMLPHP

python基础练习-猜年龄、编写登陆接口小程序-LMLPHP
 
 
 
 
 
05-11 16:25