Python Process Control

Source: Internet
Author: User

Speaking of Process Control, in fact, if you learn other languages, then learn these will feel very simple, because the principle is the same, but the syntax has changed. So as a programmer must be in-depth understanding of a language, learning a lot of language, but not proficient in some of the words, is equal to not learning, can only say that you know a little more.

Basic process structure of the program:

Sequential structure

Select structure

Loop structure

The order structure is the simplest program flow, the program according to the statement, the execution of a sentence, do not encounter logical judgment or loop situation

Select structure:

The simplest choice structure:

If True:    #statements1else:    #statements2

Multi-Branch selection structure:

If Condition1:    #statements1elif condition2:    #statements2 ... else:    #statements

In Python, where there are no switch and case statements, multiple branches are equivalent to substitution.

For loop, the loop object must be one that is an iterable (enumerable) object.

As an example:

This allows you to iterate through all the values in the list, looping through lists, tuples, collections, and dictionaries.

Range () function

Range () is a built-in function in Python that allows you to generate arithmetical progression sequences.

>>> list (range (1,10)) [1, 2, 3, 4, 5, 6, 7, 8, 9]

You can also set Delta δ.

>>> list (range (1,10,2)) [1, 3, 5, 7, 9]

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.