[PY] Simple pick Lucky Num Program

Source: Internet
Author: User

Program function:

1, the user enters the number, when the user enters the specified number, outputs the loop that he entered.

2, the second question whether or not to lose

3, if no is terminated

4, if yes continue to enter

Determines whether the input is greater than the first input

If it is greater then start looping out his second lucky num

Otherwise the loop allows the input until it is entered as greater than the first

#!/usr/bin/env python## # #coding: UTF8Lucky_num=input ('Lucky_num:') Count=1 whileCount < 100000:    #count+=1    Print 'Loop:', Countiflucky_num==Count:Print 'You have got your lucky num:', Count op=raw_input ("If you want to continue (y/n):")        ifop=="N": Break        Else:             while1: Lucky_num_new=input ('Lucky_num:')                ifLucky_num>lucky_num_new:Print "too small,you should bigger than%s pls reinput your lucky num:"%Lucky_numElse: Lucky_num=lucky_num_new Break        #print ' Loop: ', CountCount+=1Else:    Print 'Wow. That fantastic', Count

Execution Result:

[Email protected]:~/t$ python t.py lucky_num:5Loop:1Loop:2Loop:3Loop:4Loop:5You have got your lucky num:5ifYou want toContinue(y/N): ylucky_num:3too small,you should bigger than5pls reinput your lucky num:lucky_num:2too small,you should bigger than5pls reinput your lucky num:lucky_num:4too small,you should bigger than5pls reinput your lucky num:lucky_num:9Loop:6Loop:7Loop:8Loop:9You have got your lucky num:9ifYou want toContinue(y/n):

[PY] Simple pick Lucky Num Program

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.