Python basics exercises -001-guessing numbers games

Source: Internet
Author: User

Guess number games: 1-10 random numbers, players enter the number of guesses, if not guessed, give a greater than or less than to narrow the range until guessed.

Note: Is the most basic code, can be processed on this basis, for example, increase the number of guessing limit and so on.

1 #-*-coding:utf-8-*-2 #@Author: Fluttering _emmm3 ImportRandom4 Print("Welcome to the Guess number game, the number range is 1-10")5num = Random.randint (1,10)6  whileTrue:7temp = input ("Please enter the number you guessed: \ n")8Guess =Int (temp)9     ifGuess >Num:Ten         Print("the numbers are smaller than this .") One         Continue A     elifGuess <Num: -         Print("the numbers are bigger than this!") -         Continue the     Else: -         Print("Wow, that's a good guess.") -Exit"The game is over.")

Python basics exercises -001-guessing numbers 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.