Python Self-study notes (eight) Python statement

Source: Internet
Author: User

One, the print statement

1.1 Basic output, automatic branch

1.2 Print comma, you can join the previous content without wrapping, in a row

1.3 >> Redirect, output to file print >> filename, "What to enter"

Ii. Control Flow Statements

2.1 consists of the condition and execution code block . Conditions can be divided into decisions , loops , and branches

 2.2 Format (colon with 4 empty Geyong not forgotten)

2.3 If and for functions are control flow

Three, Boolean value

3.1 Lazy evaluation, circuit breaker logic

3.2 From left to right, binate to the back, there is a false return, the latter will not be executed (the easy-to-appear judgment in front, not easy to appear in the back)

3.3 Control flow and true and false values are closely related, do not misunderstand the true and False and Boolean value

3.4 Some of the most basic operators of Boolean values

and

Or

Is check share

= = Check Value

Not

Several other comparison symbols

3.5 Use small tricks, or default values. From_url = Url.get (' from ') or None

Iv. If statement (Control flow statement)

4.1 Basic format of IF

If expression: #条件表达式 Expresson result, must be true

Statement (s)

4.2 If and if else elif pass

4.2.1 if and elif instead of switch

4.3 Ternary expression 4 if True else 3

Five. While statement

Basic format for 5.1 while

While Expresson:

Statement (s)

Basic components of the 5.2 while

5.2.1 Break End While

5.2.2 continue jumps out of the current loop but does not end while

5.2.3 Else ends while executing

5.3 Note: In general applications, the while must give an end condition, otherwise it is the legendary death cycle

VI. For statement

6.1 for basic format

For item in Iterable:

Statement (s)

Basic components of 6.2 for

6.2.1 Break

6.2.2 Continue

6.2.3 Else

6.3 Note: The last iteration value of the for is preserved

PS: Loop statement else cannot be used with break

Python Self-study notes (eight) Python statement

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.