Python Note 1

Source: Internet
Author: User

An explanatory object-oriented language.

Strong type. Although it is declared for changes, once a variable has a value, it also has a type. To assign other values, you must use type conversion.

All objects, classes, functions, and modules are objects.

No Boolean, none, 0, "", [], {}, () are false.

List (list, defined as []), which is equivalent to a vector in C ++ or an array in C. Its subscript starts with 0, and negative numbers can be used.

A string consisting of single or double quotation marks. A long string can be defined together with three consecutive double quotes, exceeding multiple rows. The string can be considered as a list of many characters.

Tuple is a constant list, represented by (). The brackets are omitted. The tuples can return elements or sub-tuple by subscript. The tuples can be used to assign values to multiple variables, such as, B = (1, 2 ).

Sequence includes string, list, And tuple. They have some common operations: Using in to determine whether an element is in the sequence: If X in
Seq. Obtain the length of the sequence Len (SEQ ). Use subscript to retrieve element SQL [I] And subseq: SQL [start: end] By subscript with colon, and use + to connect
Input two seq, and use * to represent repeated seq.

A dictionary is an unordered structure. Each element is a pair, including value and key. The key type is integer or
The string and value types are arbitrary. The dictionary does not contain duplicate keys. Each element in the dictionary is a tuple, which includes
Elements, keys, and values are called pair. In pair, values are followed by keys. You can use d [Key] to obtain the value. The dictionary is enclosed.

Conditional statement if:

If <expr1 >:< one-line-Statement>

Or

if <expr1>:
<statement-block>

Or

    if <expr1>:
<statement-block>
else:
<statement-block>

Or

    if <expr1>:
<statement-block>
elif <expr2>:
<statement-block>
elif <expr3>:
<statement-block>
...
else:
<statement-block>
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.