Python Control Flow

Source: Internet
Author: User

I. Elements of the control flow

The beginning of a control flow statement is usually a "condition", followed by a block of code called a clause.

Ii. conditions of the control flow

conditions in order to determine how the next step, so as to find the Boolean value of the expression. Almost all control-flow statements use conditions.

third, code blockSome lines of code can be set as a group and placed in a "code block". You can know the beginning and end of a block of code based on the indentation of the line of code. The code block has 3 rules. 1. When the indentation is increased, the code block begins.
2. Code blocks can contain other blocks of code.
3. The indentation is reduced to zero, or the indentation for the outer enclosing block of code is reduced, and the code block ends. ---------------------------------------------Iv. Control of flow statements1.if Statementsthe clause of the IF statement (that is , the block of statements immediately following the IF statement) is executed when the condition of the statement is true . If the condition is False, the clause is skipped. in English, theif statement might read ": If the condition is true, execute the code in the clause. "In Python , theif statement contains the following sections: (1)if keyword; (2) condition (i.e. an expression that evaluates to True or False ); (3) colon; (4) the code block (called an if clause) that is indented at the beginning of the next line .

Python Control Flow

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.