1 #Coding =utf-82 ImportRandom3 4 defRoll_dice (number=3, points=None):5 ifPoints = =None:6Points = []7 whileNumber >0:8Point = Random.randrange (1,7)9 points.append (point)TenNumber = Number-1 One A returnpoints - - the defRoll_result (total): - Print('<<<<< Roll the dice! >>>>>') - if3 < Total <10 : - return 'Small' + Else: - return 'Big' + A defstart_game (): atMoney = 1000 - whileMoney >0: - Print('<<<<< GAME star! >>>>>') - Print(' you have', Money,' Now') - -You_bet = Int (input ('How much wanna bet?-')) inJudge = You_bet > Money#determine if the bet exceeds the principal - whileJudge: to Print('You have not enough money,enter again:') +You_bet = Int (input ('How much wanna bet?-')) -Judge = You_bet > Money the *Choices =['Big','Small'] $Your_choice = input ('Big or Small:')Panax Notoginseng - ifYour_choiceinchChoices: thePoins =Roll_dice () +Total =sum (poins) Aresult =Roll_result (total) theYouwin = Your_choice = =result + ifYouwin: -Money = money +You_bet $ Print('You win! the point is', Poins,'You get', You_bet) $ - Else : -Money = money-You_bet the Print('You lose! the point is', Poins,'You lose', You_bet) - Wuyi Else : the Print('Invalid Words') - Start_game () Wu Print('<<<<<game over! >>>>>') - AboutStart_game ()
[Python Learning Path] guess the size of the game