Python 0 Basic Learning path 02-python Getting Started

Source: Internet
Author: User

Unknowingly learning python for two months, from the beginning do not know how to format print, to now can hand-out ORM, this period really is

A magical process. In order to consolidate their basic knowledge, for the extension of the later buried better foreshadowing, this article when the tutor's blog to carefully review. Old

Http://www.cnblogs.com/linhaifeng/p/7278389.html's blog address.

The first day of learning is the introduction of Python, which is a simple introduction to Python basics and programming languages.

A programming and programming language

First Python is a programming language, we need to learn Python first to understand what the purpose of programming, what is the programming language, what is programming.

The purpose of programming: The Invention of computers is to replace and liberate human beings by machines, and the purpose of programming is to use human thought processes in a way that can be

Computer-recognized expressions are passed on to the computer to enable the computer to perform as automatically as the human brain.

What is a programming language: the above mentioned can be recognized by the computer expression means programming language, language is the medium of communication, and programming language is the programmer

Media that communicates with the computer.

What is programming: programming is where programmers write their own thought flow according to the grammar style of a programming language, and the result of the output is that it contains

A bunch of characters of the file. The program does not run before the same as ordinary files, only the program at run time, the characters written in the file characters have a specific grammatical meaning.

Two programming languages classification

Machine language: Directly using binary programming, direct operation of hardware;

Assembly language: Using shorthand English identifier instead of binary to write the program, the essence is still directly operating hardware;

High-level language: the use of human characters to write programs, shielding the hardware operation.

  

High-level languages must be translated into a computer-readable binary to be executed according to the translation method:

Compiled type (need compiler, equivalent to Google Translate): such as C, execution speed, debugging trouble.

Explanatory type (interpreter required, equivalent to simultaneous interpretation): Like Python, slow execution, easy commissioning

Summarize:

Machine language
The advantage is the lowest level, the fastest execution speed
The disadvantage is the most complex, the development efficiency is lowest

Assembly
The advantage is the lower level, the fastest execution speed
The disadvantage is complex, the development efficiency is lowest

Advanced language
The compiler language executes fast, does not depend on the language environment to run, the cross platform difference
Interpreted cross-platform good, a code, used everywhere, the disadvantage is that the execution speed is slow, dependent on the interpreter to run

In a nutshell: Three languages learning difficulty from high to low, execution efficiency from high to low, development efficiency from low to high. In the programming world, speed is not

is the key (bottleneck theory), the development of high efficiency is kingly.

Three mainstream programming language examples: C,c++,c#,python,php,javascript and so on.

Four Python introduction: The Tutor blog written in very detailed, this article is to review the key points of knowledge as the main purpose, it will not be elaborated.

Important: 1991, the first Python compiler was born. It is implemented in C language and can call the C language library file. From the birth of a Python

Already has: classes, functions, exception handling, core data types including tables and dictionaries, and module-based expansion systems.

Types of Python interpreters:

1, Cpython:cpython is the most widely used and the Python interpreter. This tutorial takes CPython as the subject. This interpreter was developed in C language, so called CPython. Running Python at the command line is the start of the CPython interpreter.

2. Ipython:ipython is an interactive interpreter based on CPython, that is to say, IPython is only enhanced in interactive mode, but the function of executing Python code is exactly the same as CPython. Like many domestic browsers although the appearance of different, but the kernel is actually called ie. CPython uses >>> as a prompt, while Ipython uses in [ordinal]: as a prompt.

3. Pypy:pypy is another Python interpreter whose goal is to execute speed. PyPy uses JIT technology to dynamically compile Python code (note that it is not interpreted), so it can significantly improve the execution speed of Python code. Most python code can run under PyPy, but PyPy and CPython are somewhat different, which results in the same Python code being executed under both interpreters. If your code is to be executed under PyPy, you need to understand the differences between PyPy and CPython.

4. Jython:jython is a Python interpreter running on the Java platform that compiles python code directly to Java bytecode execution.

5, Ironpython:ironpython and Jython similar, but IronPython is running on the Microsoft. NET platform of the Python interpreter, you can directly compile the Python code into. NET bytecode.

Five variables

1, the definition of variables will be: Id,type,value.

2, the equals sign compares the value,is is the ID. The same ID means that the type and value must be the same, the same type of value must be the same, but the ID may be different.

Six user-to-program interaction

1. Input in Python3: The user enters any value and is stored as a string type.

    Input in Python2: What type the user enters, what kind is stored, raw_input: equals Python3 input.

2, code comments and multiline comments, single-line comments # , multiline comments can be three pairs of double quotation marks""" """

3. file header #!/usr/bin/env python
#-*-Coding:utf-8-*-

Seven basic data types

1, int integral type: age=10 #age =int (10)

2 float Float type: salary=3.1 #salary =float (3.1)

3, complex plural type: x=1-2j; x.imag; x.real

4. String: Name= ' Egon ' #name =str (' Egon ')

5. List: students=[' Egon ', ' Alex ', ' Wupeiqi ',] #students =list ([' Egon ', ' Alex ', ' Wupeiqi ',])

6. Dictionary: info={' name ': ' Egon ', ' age ': +, ' sex ': +} #info =dict ({' name ': ' Egon ', ' age ': $, ' sex ': 18})

7, Boolean: Boolean, a true one false, all data types have a Boolean value, except None, 0, empty three cases are false, the rest are true.

8, mutable and immutable: Variable type: In the case of the same ID, value can be changed, it is called a mutable type, such as a list, a dictionary;
Immutable type: Once the value changes, the ID also changes, which is known as the immutable type (ID variable, which means that a new memory space is created);

Eight formatted output:

1.%s String placeholder: You can receive a string, or you can receive the digital print (' My name is%s,my '%s '% (' Egon ', 18)

2. Three ways to use format ()

Nine basic operators

1. Arithmetic operations

2. Comparison operation

  

3. Assignment Operation

  

4. Logical Operation

Ten Process Control

1, If...else

2. While loop

3. While+else: When the while loop executes normally and the middle is not interrupted by a break, the statement after the else is executed.

4. For loop

  

Python 0 Basic Learning path 02-python Getting Started

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.