Python full stack development: Python loop statement while

Source: Internet
Author: User

While loop

Why would there be loops like this statement?

To give a simple example: we want to calculate the number of even numbers within 0-100, and this time we need to loop this statement

Then one might say, "What 0+2+4+.......+98 can be calculated?"

Suddenly our condition changed: Calculate the number of even numbers within 0-10000000 and

It can be imagined that this is how a workload, the cycle is just to solve this problem.

Figure:

The representation of a while loop in Python is like.

Grammatical form:

 while Loop condition: Loop body (code block) loop Body (code block)     Loop Body (code block)             ...

eg

# calculates an even number of 100 and count= = 0                # Total  while Count <:       If count%2==0:    # to determine if an even        sum+=count    # is an even number added    count+=1            # Count plus one

Python full stack development: Python loop statement while

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.