Python Learning Comprehension Section 2nd

Source: Internet
Author: User

Today is the first chapter of the Knowledge Supplement, and the new knowledge of learning.

First, the module is initially, and the module includes the standard library and third-party libraries (to be used for download and installation). It is important to note that the name of the filename cannot be the same as the imported library name. The first is the standard library of learning, the standard library in the SYS module and the OS module, for example,

The third party libraries can be written by itself, and calls itself to write the module.

Python is an interpreted language. Like the C language is a compiled language, the compiler language means that before the program executes, the program will be compiled by the compiler process, the program into machine language (0 and 1). In the case of Python, an interpreted language does not compile, but is interpreted and run by the interpreter when the program is running.

Then we learned the ternary operation:

When A>b, assigns a value to d,a less than or equal to B, assigns C to D.

The next step is learning to convert between conversions. One of the more important is the hexadecimal and binary conversion, will be binary every four bits good, in hexadecimal notation, why is the 4-bit one partition reason is (1111=15).

The most important new feature of Python3 is the clearer division of text and binary data.

Use of the list to learn

1. Naming rules

2, the following introduction (1) Increase (2) Delete (3) Change (4) Check

(1) Increase

Names.append ("Lei") #追加值放在列表最后

Names.insert (1, "Chen") #1表示插的位置 to write where you want to go.

(2) Delete (3 methods, you can delete the list of elements or the variable itself)

Act 1:

Names.remove ("Chen")

Print (names)

Act 2:

Del Name[1]

Print (names)

Act 3:

Names.pop ()

Print (names) #如果pop () The last element is deleted by default, otherwise the corresponding subscript position element is deleted

(3) Change

Names[2]= "Xie" #直接赋新值

(4) Check

Print (Names.index ("Xie")) #返回下标

-------------------------------------------------

Print (Names.count ("Chen")) #计数, such as the number of classmates with the same name in a class

Names.reverse () #反转列表

Names.sort () #排序, all letters in alphabetical order

New definition name2=[1,2,3]

Names.extend (Names2) #将names2扩展在name后面

Python Learning Comprehension Section 2nd

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.