[Python Learning Path] guess the size of the game

Source: Internet
Author: User

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

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.