Python implementation roll dice guess size function upgrade not to raise and three operators SMS verification filter

Source: Internet
Author: User

Roll Dice Game Upgrade

This change increases betting function, start capital 1000 yuan, each time the odds are one times, the money gambled out.

Source:

1 #!/user/bin/env python2 #-*-coding:utf-8-*-3 #Author:qinjiaxi4 ImportRandom5 #shake three dice at a time and put the results in the list6 defRole_a_dice (number = 3, point =None):7     Print('Let\ ' s play a game')8     ifPoint isNone:9Point = []Ten      whileNumber >0: OnePoint.append (Random.randint (1, 6)) ANumber-= 1 -     return Point - #convert result to ' size ' string the defDice_reslut (total): -IsBig = <= Total <= 18 -Issmall = 3 <= Total <= 10 -     ifIsBig: +         return "Big" -     ifIssmall: +         return  "Small" A defStart_game (Money = 1000): at      whileMoney >0: -         Print("-----GAME START-----") -choices = ['Big','Small'] -U_choices = input ('pls enter your choice:') -         ifU_choicesinchChoices: -money_choice = Int (input ('How much wanna bet?-')) inPoints = Role_a_dice ()#Call function Roll dice to get three dice results -Totals = SUM (points)#Three results add final points toResluts = Dice_reslut (totals)#call the function to get the final point converted to a string +             ifU_choices = =resluts: -                 Print('The points are: {} Congratulations on your guess.'. Format (points)) theMoney + =Money_choice *                 Print('You gain {}, you have:{} now'. Format (Money_choice,money)) $             Else:Panax Notoginseng                 Print('the number of points is: {} sorry, wrong guess.'. Format (points)) -Money-=Money_choice the                 Print('You lost {}, you have:{} now'. Format (Money_choice, money)) +         Else: A             Print('Invalid words.') the Start_game () +     Else: -         Print('GAME over') $Start_game ()
Three major carrier SMS verification filter

If the number of three operators to send text messages, numbers less than 11 tips

Source:

1!/user/bin/env python2 #-*-coding:utf-8-*-3 #Author:qinjiaxi4 5 defVerificate_number ():6      whileTrue:7Cn_mobile =[134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705]8Cn_union = [130,131,132,155,156,185,186,145,176,1709]9cn_telecom = [133,153,180,181,189,177,1700]TenNumber = input ('pls enter your number:') Onefirst_three = Int (number[0:3]) Afirst_four = Int (number[0:4]) -         ifLen (number) = = 11: -             ifFirst_fourinchCn_mobileorFirst_threeinchCn_mobile: the                 Print('operator is China Mobile' ) -                 Print('we\ ' re sending verification code via text to your phone {}'. Format (number) -                  Break -             elifFirst_fourinchCn_unionorFirst_threeinchcn_union: +                 Print('operator is China Union') -                 Print('we\ ' re sending verification code via text to your phone {}'. Format (number) +                  Break A             elifFirst_fourinchCn_telecomorFirst_threeinchcn_telecom: at                 Print('operator is China Telecom') -                 Print('we\ ' re sending verification code via text to your phone {}'. Format (number) -                  Break -             Else: -                 Print('No such a operator') -         Else: in             Print('Invalid Length, your number should is in one digits') -Verificate_number ()

Python implementation roll dice guess size function upgrade not to raise and three operators SMS verification filter

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.