#!/usr/bin/env python
#-*-Coding:utf-8-*-
# __author__ = "Sandu"
My_age =27
Count =0
While Count <3:
Guess_age =intInput "Please enter your guess Age:"))
Count + = 1
if guess _age > My_age:
print ( "Age guess Big")
if count = = 3:
print (" has exceeded the number of inputs ")
elif guess_age < my_age:
print (" Age Guess small ")
if count = = 3:
print (" has exceeded the number of inputs ")
else:
print (" Congratulations, you guessed it! ")
< Span style= "COLOR: #008080" > < Span style= "COLOR: #0000ff" > < Span style= "COLOR: #0000ff" > break
########### #改良版本 #####################
#!/usr/bin/env python
#-*-Coding:utf-8-*-
# __author__ = "Sandu"
My_age =27
Count =0
while count < 3:
Guess_age = int (input (" Please enter your guess Age: "))
if guess_age > My_age:
print (" Age guess Big ")
elif guess_age < my_age:
print (" Age guess small)
else:
print ( "Congratulations, you guessed it!" ")
break
count + = 1
else:
print (
< Span style= "COLOR: #008080" > < Span style= "COLOR: #0000ff" > < Span style= "COLOR: #0000ff" > < Span style= "COLOR: #000080" >
The
Implementation allows the user to constantly guess age, but only to a maximum of 3 opportunities, more than the number of guesses to quit the program.