Head First Python Study Notes 01

Source: Internet
Author: User

Python 3 provides more than 70 built-in functions. This is Python's "fully functional" point of view: Python already contains enough built-in functions so that you can do most of the work, instead of relying on third-party code.


Python list:

The Python list is a high-level collection designed to store "related things. The list does not care about the types of these things. The list is only available to provide a mechanism. Therefore, it is normal to store mixed data in the list.

The Python list can access data items in the list by subscript like an array and can be scaled as needed, but it does not support cross-border access checks like some languages. If you try to access a non-existent data item, Python returns an IndexError as a response.

Add a data item to the end of the list: cast. append ("Gilliam ")

Delete the last data item at the end of the list: cast. pop ()

Add a data item set at the end of the list: cast. extend (['gillim', 'chapman'])

Add a data entry before a specific position in the list: cast. insert (0, "Chapman ")

Delete a specific data item in the list: cast. remove ('gillim ')


Print () in shell, which is different from Python 2. The print function in Python 3 must be enclosed in brackets.


Evaluate the length of a list or character from or dictionary: len ()


Determine whether a variable is of a certain type: isinstance (foo, type), such as isinstance (mvoes, list), and whether moves is of the list type.


Define a function using def:

Def function name (optional ):

Function Code Block


View Python help information.

Enter dir (_ builtins _) to view the list of built-in methods provided by Python. All lowercase words in the list are BIF (built-in method ).

To view the function of a BIF, you can type help (len) in shell to get the function description of len BIF.

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.