Python Learning notes (1)

Source: Internet
Author: User

Starting today to learn Python formally, the tutorial looks at Liu Xuefeng Teacher's Python 2.7 tutorial. Link here: http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000

This study note is mainly to summarize the main points of knowledge and I do not understand the problem, the main purpose is to urge themselves, there are many shortcomings hope that you will enlighten. All right, the crap's over. Start Note (1)

Python2.7.5 and editor Sublime Text2 were installed before starting the study.

I. Data type

1. People who have learned static language the first impression of Python is that there is no type for this variable, yes, Python does not need to define a type, each type can be assigned to each other or even size, because the variable name is the address to the storage object. The basic data types and C,java are almost never said.

2. Special type: List,tuple,dict,set These types are python built-in data types

1) List: Similar to array, can be accessed with subscript, insert method inserts (position,value), delete trailing element pop (), etc.

2) Tuple: Unlike list, the tuple cannot be changed after initialization and is more secure than list.

3) Dict: Full name dictionary, also known as map in other languages, with key-value (Key-value) storage, with extremely fast lookup speed.

    4) set is similar to Dict and is a set of keys, but does not store value. Because key cannot be duplicated, there is no duplicate key in set.

Two. Functions
1. In Python, define a function to use the def statement, write down the function name, parentheses, the arguments in parentheses, and the colon : , and then, in the indent block, write the function body, and the return value of the function is returned with a return statement. Where the return value can have more than one, the equivalent of returning a tuple type of data.
2. Define an empty function to use the PASS statement otherwise will be error, so need to use to not perform the operation of the case to use pass
3. Define functions in Python, which can be combined with required parameters, default parameters, variable parameters, keyword arguments, and named keyword parameters, except that mutable parameters cannot be mixed with named keyword parameters. Note, however, that the order of the parameter definitions must be: required, default, variable/named keyword, and keyword parameters.
Today will be updated to this, the content will be revised again, tomorrow continue to learn Python!

Python Learning notes (1)

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.