2015.5.25 the first world to download Python IDLE, write a guess the number of small game to familiarize yourself with the language:
1Times=62letters=[100]3 forIinchRange (1, times):4A = input ("Input the number you guess:")5 Try:6b =Int (a)7 ifisinstance (b,int):8 ifI <5:9 ifInt (a)inchLetters:Ten Print("%s is the right answer, you win!"%a) One Break A Else: -Sen1 ="%s is isn't the right answer,"%a - ifInt (a) <Letters[0]: theSen2 ="and It is smaller,please try again." - Else: -Sen2 ="and it is greater, please try again." -Sen ="%s%s"%(SEN1,SEN2) + Print("%s"%Sen) - Continue + Else: A Print("You lose!") at Else: - Print("You should input an integer number") - exceptException as err: - Print("You should input an integer number.") -Input"Input any key to quit:")
Only 4 chances, all wrong. Even if you lose, including the type control of the data entry, this is the case:
Write a guess number game in Python