#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author:army.han
'''
#用while循环猜数
age_laobi = 56
conut = 0
while conut<3:
guess_age = int(input("guess age:"))
if guess_age == age_laobi:
print("Yes you got it .")
break
elif guess_age < age_laobi:
print("you are tink big")
else:
print("you are tink smaller.")
conut += 1
else:
print("三次 没猜对 退出")
'''
'''
#用for循环猜数
age_sb = 48
for i in range(3):
guess_age= int(input("enter age:"))
if guess_age == age_sb:
print("猜对了")
break
elif guess_age>age_sb:
print("你猜大了")
else:
print("你猜小了")
else:
print("你猜了3次,都错了,退出了")
'''
#慕课网学习猜数
'''
import random
a = random.randint(1,50)
while True:
guess_nu= int(input("pleses,enter 1-50:"))
print ("pleses,enter 1-50:")
if guess_nu > a:
print ("Guess Bigger",guess_nu)
elif guess_nu < a:
print ("Guess Smaller",guess_nu)
else:
print ("Guess OK Game Over")
break
'''
import random
age = random.randint(1,100)
for i in range(10):
if i <5:
guess_unm= int(input("Enter 1,100:"))
if guess_unm == age:
print("猜对了")
break
elif guess_unm >age:
print("think smaller..")
else:
print ("think big...")
else:
print("5次没才对 退出。")
break
转载于:https://www.cnblogs.com/army0627/p/5985273.html