12. Circulation

Source: Internet
Author: User

While

# ask for 1-100 and A, sum = 1, 0 while a < 101:    = a + 1, sum + a    #
   
     sum = sum + a    
    # 
     a = a + 1
    print
    #
    5050,
   

While...else

 #  while Loop using the Else statement executes the ELSE statement when the conditional statement is False  Count = 0  while  count < 5:  print  (Count, " Span style= "COLOR: #800000" > less than 5   ", End="   )  #  0 is less than 5, 1 is less than 5, 2 is less than 5, 3 is less than 5, 4 is less than 5,  count + = 1else  :  print  (count, "   greater than or equal to 5   ") #  5 is greater than or equal to 5  

For in

 for  in range (1,3):    print(i,end=","#,

For in ... else

# the For loop uses the Else statement to execute the ELSE statement when the conditional statement is False  for  in range (1,3):    print(i,end=","#1, 2,  Else:    Print(i," greater than or equal to 3"# 3 is greater than or equal to 3

1. Range () traversal function
2. Break jumps out of the current loop
3, continue jump out of this cycle to continue the next cycle
4, pass empty statement, the general use of placeholder statements

12. Circulation

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.