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