The path to learning Python

Source: Internet
Author: User

Directory Outline
    1. Python Introduction
    2. Python application areas
    3. Python pros and cons
    4. Python interpreter
    5. Python history
    6. Python installation
    7. Python Program Writing Hello Word
    8. Python variables
    9. Python user input
    10. Python expression (if: Elif. Else
First, Python introduction

The founder of Python is Guido van Rossum. Python was born during Christmas in 1989.

Second, the main application areas of Python
    • Cloud Computing: OpenStack is developed in Python language
    • Web Development: A typical web framework has Django
    • Scientific Computing \ Artificial Intelligence: Typical library numpy,scipy,matplotlib,enthought Librarys,pandas
    • system Operation and maintenance: essential for operation and maintenance personnel
    • Financial:
    • Graphical GUI: Pyqt,wxpython,tkinter

What is the language of Python:

Programming languages are categorized mainly by the following angles. Compilers and interpreters, static and dynamic languages, strongly typed languages, and weakly typed languages. The following are explained:

The difference between the compiler and the interpreter:

Compiler: Each statement of the source program is compiled into a machine language, and saved as a binary file, so that the runtime computer can be directly in the machine language to run the program, fast;

Interpreter: In the execution of the program, only one explanation of the machine language to the computer to execute, so the speed is not as fast as the compiled program to run. This is because the computer does not directly recognize and execute the statements we write, it only knows the machine language (binary form)

Compiler: It is the same as assembly language, and there is a translation program to convert our source code, generate the corresponding executable code. This process is a bit more professional, called compilation (Compile), and the program responsible for compiling is naturally called the compiler (Compiler)

Interpreted: Converts all the code into a machine language at once and then writes the executable file. (If you are going to read a foreign language book, and you do not know the foreign language, then you can find a translator, give him enough time to translate the whole book from start to finish, and then the language of the book to you to read, or you immediately let the interpreter assist you to read, let him sentence to you to translate, if you want to look back to a chapter , he will have to re-translate it for you. )

The difference between a static language and a dynamic language:

Static language: Dynamic type language refers to the language of data type checking during run time, that is, when programming in a dynamic type language, you never have to specify a data type for any variable, and the language will record the data type internally when you assign it to a variable for the first time. Python and Ruby are a typical dynamic type language, and many other scripting languages, such as VBScript, are also dynamic type languages.

Dynamic language: Static type language is just the opposite of dynamic type language, its data type is checked during compilation, that is, when writing a program to declare all variable data types, C + + is a typical representative of static type language, other static type language also has C #, Java and so on.

Strongly typed language: a language that enforces the definition of a data type. In other words, once a variable is assigned a data type, it is always the data type if it is not cast. If you define an integer variable A, it is not possible for a program to treat a as a string type at all. Strongly typed definition language is a type-safe language

Weakly typed language: a language in which data types can be ignored. In contrast to strongly typed definition languages, a variable can assign values of different data types

Iii. advantages and disadvantages of Python


    1. High development efficiency. Python has a very powerful third-party library, basically you want to achieve any function through the computer, the Python official library has the corresponding modules to support, directly download the call, on the basis of the base library to develop, greatly reduce the development cycle, to avoid repeating the wheel.
    2. High-level language-when writing programs in the Python language, you don't have to consider the underlying details such as how to manage the memory used by your program
    3. Portability-because of its open source nature, Python has been ported on many platforms (modified to make it work on different platforms). If you are careful to avoid using system-dependent features, all of your Python programs can run on almost any system platform on the market without modification.
    4. Extensibility-If you need a piece of your critical code to run faster or you want some algorithms to be private, you can write some of your programs in C or C + + and then use them in your Python program.
    5. Embeddable-You can embed python in your C/C + + program to provide scripting functionality to your program users.


    1. Code can not be encrypted, because Python is an explanatory language, its source code is stored in the form of a name, but I do not think this is a disadvantage, if your project requires that the source codes must be encrypted, then you should not use Python in the beginning to implement.
    2. Threads do not take advantage of multi-CPU problems, which is one of the most common drawbacks of Python, the Gil, the Global Interpreter lock (interpreter lock), is a tool that the computer programming language interpreter uses to synchronize threads so that only one thread executes at any moment, The python thread is the native thread of the operating system. (There is a compromise solution to the problem)
iv. Python interpreter

When we write the Python code, we get a text file that contains the Python code for the .py extension. To run the code, you need the Python interpreter to execute the .py file. Since the entire Python language is open source from spec to interpreter, it is theoretically possible for anyone to write a Python interpreter to execute Python code (which is difficult, of course) as long as the level is high enough. In fact, there are a number of Python interpreters.


When we downloaded and installed Python 2.7 from the official Python website, we immediately got an official version of the interpreter: CPython. This interpreter was developed in C language, so called CPython. Running at the command line python is to start the CPython interpreter. CPython is the most widely used Python interpreter. All the code for the tutorial is also executed under CPython.


Ipython is an interactive interpreter based on CPython, meaning that Ipython is only enhanced interactively, but the functionality and CPython of executing Python code are exactly the same. Like many domestic browsers although the appearance of different, but the kernel is actually called ie. CPython >>> is used as a prompt, while Ipython is used In [ 序号 ]: as a prompt.


PyPy is another Python interpreter whose goal is to perform 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.


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


IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft. NET platform that compiles python code directly into. NET bytecode.


Python has a lot of interpreters, but the most widely used is cpython. If you want to interact with the Java or. NET platform, the best approach is not to use Jython or IronPython, but to interact via network tuning to ensure the independence of each program.

v. History of Python
  • In 1989, in order to pass the Christmas holiday, Guido began to write the Python language compiler. The name Python, from Guido's beloved TV show Monty Python's Flying Circus. He hoped that the new language, called Python, would fit his ideals: create a language that is all-powerful, easy to learn, easy to use, and extensible, between C and Shell.
  • 1991, the first Python compiler was born. It is implemented in C language and can call the C language library file. From birth, Python already has: classes, functions, exception handling, core data types including tables and dictionaries, and module-based expansion systems.
  • Granddaddy of Python Web frameworks, Zope 1 is released in 1999
  • Python 1.0-january 1994 adds lambda, map, filter and reduce.
  • Python 2.0-october 16, 2000, added a memory recovery mechanism that forms the basis of the Python language framework Now
  • Python 2.4-november 30, 2004, the same year now the most popular web framework Django was born
  • Python 2.5-september 19, 2006
  • Python 2.6-october 1, 2008
  • Python 2.7-july 3, 2010
  • In November, it is announced that Python 2.7 would is supported until 2020, and reaffirmed that there would is no 2. 8 release as users were expected to move to Python 3.4+ as soon as possible
  • Python 3.0-december 3, 2008
  • Python 3.1-june 27, 2009
  • Python 3.2-february 20, 2011
  • Python 3.3-september 29, 2012
  • Python 3.4-march 16, 2014
  • Python 3.5-september 13, 2015

Vi. installation of Python


1. Download the installation package 2. Install the    default installation path: C:\PYTHON30 3. Configure environment Variables    Right-click My Computer --Properties--Advanced system settings--environment variables--Find path in system variables, click Edit at the end of the add; C:\python30 (note here). Then save to

  Linux, Mac

1. No installation, with Python     PS: If it is python2.x please upgrade to 3.0

Vii. writing a program Hello Word


1 # /usr/bin/env python 2  3 Print " Hello World "
1 #  23"HelloWorld"
Shell Viii. variables

  Variable definition rules:

Variable names can only be any combination of letters, numbers, or underscores. The first character of a variable name cannot be a number the following keywords cannot be declared as variable names and, as, assert, break, class, continue, Def, Del, elif, else, except, E Xec, finally, For,from, Global, if, import, in, are, lambda, not, or, pass, print, raise, return, try, while,with, yield


When Line gaze: # commented content Multiline Comment: "" "" "" "or" "" commented Content ""
1 # !/usr/bin/python 2 #  3"honglin.yu"45   #  6Print(name)
1 # /bin/bash 2 3 # Assign a value to a variable name 4 name="Welcome to your Beijing"56#  Print out the value of the variable name 7 Echo $name
Shell Nine, user input
1 # user foreground input and assign value to variable name 2 name = input ("what' s your name? ") " )34# print out the foreground input information 5 print ("  """)
1 #/bin/bash2 3 #User Foreground input4Read-p"What ' s your name"Uo5 6 #Assign a value to a variable name7Name="Welcome to Beijing"8 9 #Print information about the information and variables entered in the foregroundTen Echo $Uo $name One  AShell
Shell 10. Expression

Expression if...elif......else-statement


#Python if......else  Statement #if ... else statement #<strong> the foreground input. You need to be aware of the symbol (symbol:  = =  "") when writing if...else statements. Variables must be added with a space < /strong> a = input ("age_a:") b = Input ("Age_b:") if a = = "Ten" and b = = "": Print (A, b    ) Else:    print ("Gun ...")

#Python if......elif......else<br><br> #猜年龄的游戏开始 # Set Variable user_age = 30# User foreground input age. Information entered in Python in the background defaults to the str string type user_input = Int (input ("Please enter the old:")) #if条件判断if User_input = = user_age:< C5/>print ("Ipuut errors,please Enter Age")     elif user_input < user_age:    print ("Errors, please enter age.", " The correct age is: ", user_age) Else:    print (" idiot ")


#if. Else Statement <br>#!/bin/bash#<strong> Note: You cannot add a space after a variable in the shell. There must be spaces before and after the comparison and need to be written in []. Then the conclusion cannot be directly followed by [] Post. A newline is required. The following </strong> a=10b=20 if  [$a = = $b]then    echo "This is a and  B:" $a $b else    echo  "Gun .... "    Echo  " A and B: "$a $b fi


The path to learning Python

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: 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.