Python Process Control

Source: Internet
Author: User

4. Process Control and recycling

Age = Raw_input (' Age: ') if Age>40:print ' old! ' Elif age>30:print ' young! ' Else:print ' younger! ' The If execution ends directly when the case is matched, not exiting else, the declaration of the variable can be omitted as equals = the definition of the assignment is a double equal = = = For loop for * in *:

5.while Cycle

The while loop defaults to a dead loop for the loop has a start end, the number of cycles  print_num = input (' which loop do you want it to is printed out? ') Count = 0while Count < 100000:       if count = print_num:          &NBSP ; print ' There got  the number: ',count            choice = raw_input (' Do you want to Continue the loop? (y/n) '             if choice = = ' n ':                 break            else:                  W Hile print_num <= count:                         print _num = InOut (' which loop do you want it to be printed out? ')                          print u "pass"     &NBSP ;  else:              print ' Loop: ',count  &nbsp    count  +=1       else:      print ' Loop: ', Count

Python Process Control

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.