I took a look at the python getting started book and used a small game to train my hands. In fact, there are just a few lines of code, and only the novice and the cheek-to-face loggings make me look ugly.
Just like Zhang xzhong, come to Shanghai, and the tianchao naval forces are invincible.
Here is the use of a random function and A while LOOP statement.
#-*-Encoding: UTF-8-*-''' Created on August 1, May 8, 2014 @ author: Administrator ''' import randomkeys = random. randint (1,100) # The function is used to give a random number, then let's guess the number of times = 0 # The number of guesses your_key = 0 # define a variable print that waits for the value entered by the user. "You are playing a number-guessing game, you have 6 chances to guess @ "while your_key! = Keys and times <6: your_key = int (raw_input ("enter a number that you think is correct:>") if your_key> keys: print "the number you entered is too large. Please enter a smaller value :) \ n" elif your_key