Python-based simple guess digital game, python-based guess digital
This example describes a simple guess digital game implemented by python. Share it with you for your reference. The details are as follows:
Given a number between 1 and 99, the user can guess the number. When the user guesses the error, the user will be prompted to guess whether the number is too large or too small, until the user guesses the number, the less you use the right number, the better your score.
Import randomn = random. randint (1, 99) guess = int (raw_input ("Enter an integer from 1 to 99:") while n! = "Guess": print if guess <n: print "guess is low" guess = int (raw_input ("Enter an integer from 1 to 99:") elif guess> n: print "guess is high" guess = int (raw_input ("Enter an integer from 1 to 99:") else: print "you guessed it! "Break print
I hope this article will help you with Python programming.