Learn python in the first quarter of the fourth Chapter 3.6 example Project guess number game-core code--guessing number--random function and mask error code can be copied directly using the Entertainment wrapper function

Source: Internet
Author: User

1 #guess numbers--core code--guessing times--random functions and masking error codes2 3 ImportRandom4Secrst = Random.randint (1,99)5 6Number =Secrst7 8Amount = Random.randint (3,8)9 Print('the number of games this time is', Amount,'Times')Ten  OneCount=0 A  whilecount<=Amount: -     Try: -Conversion=input ('Please guess the numbers') theguess=Int (conversion) -  -         ifGuess = =Number : -             Print('guess right.') +              Break -         elifGuess >Number : +             Print('big.') A         Else: at             Print('it's small.') -  -Count=count+1 -  -         ifcount==Amount: -Countine=input ('any key to start again, "N" key to exit the game') in             ifCountine! ='N': -Count=0 to             Else: + exit () -     except: the         Print('Please enter a number instead of the other')
guess numbers--random functions and masking error codes

Import Random
Secrst = Random.randint (1,99)

Number = Secrst

Amount = Random.randint (3,8)
Print (' The number of games ', amount, ' Times ')

Learn python in the first quarter of the fourth Chapter 3.6 example Project guess number game-core code--guessing number--random function and mask error code can be copied directly using the Entertainment wrapper function

Related Article

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.