Python Conditional Statement Learning

Source: Internet
Author: User

The Python conditional statement learns one, pre-concept preparation code block:

A code block refers to the content of the code that is indented after a colon. The code block defaults to four spaces, which you can indent with the TAB key.

The basic form of the IF condition statement: 1, the basic if statement

The basic if statement is actually basic:

If condition:

The code of the established line

..................

Else

Code for a non-established line

..................

2. Nested IF statements

The nested statement is the IF inside if:

If condition:

If condition 2:

Set up a code block

..................

Else

Code block not established

.....................

Else

Code block not established

..................

3. Multi-Conditional if statement

If condition:

Set up code block 1

..................

Elif Condition 2:

Set up code block 2

..................

Elif Condition 3:

Set up code block 3

..................

..................

Else

Code block not established

..................

4. Pass

The keyword in Python does not perform any action to skip directly. That is useless, but he occupies a block of code, the purpose is to make the code is not wrong, usually before the code is written, the relationship between the judgment or the loop is not fully established, but there is a need to continue the following code. Use pass to occupy the place. The advantage is that the execution of the time will not be an error, or write only if the condition without the code block will be running the code in the event of errors.

Python Conditional Statement Learning

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.