Fifth day Python learning record

Source: Internet
Author: User

While loop

#第50次不打印, 第60-80次 prints the square of the corresponding value

1Count =02 3  whileCount <= 100:4     ifCount = = 50:5         Pass6     elifCount >= 60 andCount <=80:7         Print(count*count)8     Else:9         Print("Loop", Count)Ten  OneCount + = 1 A  - Print("------Loop is ended-------")

Dead loop (Dead Loop)

Count = 0 while true:#true itself is true    print("  Forever-------", Count)        + = 1

Break is used to completely end a loop, jumping out of the loop body to execute the statement behind the ring continue just terminates the loop, then executes the loop behind it.

 count = 0  while  count <= 100:  print  ("    Span style= "COLOR: #800000" >loop   " ,count)  if  count = = 5:  break   count  + = 1print  ( Span style= "COLOR: #800000" > " ------out of loop------- " ) 
Count = 0 while Count <=:    print("", Count)    if count = =5        :continue    + = 1print ("------out of loop-------")

0-100 loops, skipping 6 to 94

Count = 0 while Count <=:    + = 1    if and Count <:          continue    print("", Count)Print ("------out of loop-------")

Fifth day Python learning record

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.