Woody's Python Learning Note 3

Source: Internet
Author: User

Python operators

Python logical operators

and Boolean with-if X is False,x and Y returns false, otherwise it returns the computed value of Y.

or Boolean or-if x is true, it returns true, otherwise it returns the computed value of Y.

Not Boolean no-if X is true, returns False if X is False, which returns TRUE.

Python member operators

Python supports member operators, and a test instance contains a series of members, including strings, lists, or tuples.

In if the value found in the specified sequence returns True, False is returned.

Not if the value in the specified sequence is not found to return true, otherwise false is returned.

Python identity operator

The identity operator is used to compare the storage units of two objects

is to determine whether two identifiers are referenced from an object, X is y if ID (x) equals ID (y), is returns result 1.

Is does not determine whether two identifiers are referenced from different objects, X is not y if ID (x) is equal to ID (y), is returns result 1.

There are no switch statements in Python, instead of using elif.

Python while Loop statement

The while statement has two other important commands, Continue,break, to skip the loop, continue to skip the loop, and break to exit the loop.

Looping with Else statements

In Python, for...else means that the statement in for is no different from normal, and the statement in else is executed when the loop is executed normally (that is, for not breaking out by break), While...else is the same. If you use loop nesting, the break statement stops executing the deepest loop and starts executing the next line of code

The Python for loop can traverse any sequence of items.

Another way to perform a loop traversal is through indexing, such as:

Len () returns the length of the list, which is the number of elements.

Python Pass is empty statement, is to eat the integrity of the program structure, basically is meaningless.

Woody's Python learning Note 3

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.