"Python27" guessing random number of small games

Source: Internet
Author: User

Game rules:

Guess a random number, if you guessed the right to give the corresponding guessing success prompt (custom text), if the guess big or guess small, give the corresponding hint, but the total number of guesses is three times, each guess the wrong time to re-guess, to the user hint the remaining guess number

The implementation is as follows:

Import Random

guess = Int (raw_input ("Please enter the number you guessed:"))
Random_num = Random.randint (1,8)
Print Random_num
While guess! = random_num:
Print "You guessed wrong Oh!" "
For I in range (3):
guess = Int (raw_input ("I'll give you the%s chance next time, please continue to guess:"% (3-i)))
If guess > Random_num:
Print "You guessed too much."
Elif Guess < random_num:
Print "You guessed too little."
Else
Break
Else
Print "opportunity to use, not to play with you"
Break
Else
Print "You are too powerful, this can be guessed, but guess right is not rewarded!" \ n "\
"Don't guess, it's too hard to guess."

"Python27" guessing random number of small games

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.