I. Programming and programming languages
The purpose of programming:
The invention of the computer is to replace/liberate the human being by machine, and the purpose of programming is to pass the human thought process to the computer according to some kind of computer-recognized expression, so as to make the computer perform automatically like a human brain/computer.
What makes a programming language?
The above mentioned can be the computer can express the way to become a language, language is the medium of communication, and programming language is the programmer and computer communication media. In the programming world, computers are more like human slaves, and the purpose of human programming is to command slaves to work.
What makes programming?
Programming is the programmer, according to the requirements of their own thinking process according to the grammar style of a programming language to write down, the result of output is a bunch of characters of the file.
Emphasis: Programmers do not run before the same as ordinary files, only the program at run time, the file written by the word characters have a specific grammatical meaning
II. Classification of programming languages
机器语言:站在计算机(奴隶)的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件;汇编语言:站在计算机(奴隶)的角度,简写的英文标识符取代二进制去编写程序,本质仍然是直接操作硬件;高级语言:站在(奴隶主)的角度,说人话,即用人类的字符去编写程序,屏蔽了硬件操作。
High-level language is closer to human language, resulting in: it must be translated into a computer can read the binary, before it can be executed, according to the translation method is divided into:
1, compiled type (need compiler, equivalent to Google Translate): such as C, fast execution speed, easy to debug
2. Explanatory type (interpreter required, equivalent to simultaneous interpretation): such as python, slow execution, convenient mode
- Summarize:
Machine language:
优点是最底层,执行速度最快缺点是最复杂,开发效率最低
Assembly:
优点是比较底层,执行速度最快缺点是复杂,开发效率最低
Advanced Language:
编译型语言执行速度快,不依赖语言环境运行,跨平台差解释型跨平台好,一份代码,到处使用,缺点是执行速度慢,依赖解释器运行
==ps: Speed is not the key (bottleneck theory), the development of high efficiency is kingly = =
Iii. introduction of Python
Python的创始人为吉多·范罗苏姆(Guido van Rossum)。1989年圣诞节期间,Guido开始鞋能够解释Python语言语法的解释器,Python这个名字,来自Guido所挚爱的电视剧Monty Python’s Flying Circus。他希望这个新的叫做Python的语言,能符合他的理想:创造一种C和Shell之间,功能全面,易学易用,可拓展的语言。Python可以应用于众多领域,如:数据分析、组建集成、网络服务、图像处理、数值计算和科学计算等众多领域。
The history of Python (interpreter)
In 1989, Guido began writing the Python language compiler.
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 (here to explain why the 08 3.0, 2010 instead of the introduction of 2.7?) is because 3.0 is not compatible with 2.0, causing everyone to refuse to upgrade 3.0, but the official can only launch 2.7 transition version)
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
Python 3.6-2016-12-23 release version python3.6.0
What kinds of Python are there?
We now know that Python is an interpreted language, the code wants to run, must be executed through the interpreter, the Python interpreter itself can also be regarded as a program (translation of the lawsuit is not important), what language is this program developed? The answer is in several languages. What? Because Python has several kinds of interpreters, each based on different languages, each with different features, but can run our Python code, see below:
The Cpython:cpython is the most widely used Python interpreter. This tutorial takes CPython as the subject.
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 Python at the command line is the start of the CPython interpreter.
IPython
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 uses >>> as a prompt, while Ipython uses in [ordinal]: as a prompt.
PyPy 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
Jython is a Python interpreter running on the Java platform that compiles python code directly to Java bytecode execution.
IronPython
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.
Iv. variables
What is a variable
Variable is the amount of change, the core "change" and "quantity" two words, change, that is, the amount of measurement state.
Why do we have variables
The essence of program execution is a series of state changes, which is the direct embodiment of program execution, so we need a mechanism to reflect or to save the program execution is the change of state.
Definition Specification for variables
Variable names can only be any combination of letters, numbers, or lower loops
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 ', ' exec ', ' Finall Y ', ' for ', ' from ', ' global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' Try ', ' While ', ' with ', ' yield ']
How to define:
Hump body
Ageofoldboy = 20
Underline (recommended)
Age_of_oldboy = 20
How to define a bad name for a variable
1, the variable name is Chinese, pinyin
2, variable name too long
3, variable nouns do not convey
The definition variable will have: ID, type, value
1, the equals sign compares the value,
2, is the ID of the comparison is
Emphasize:
1, the same ID, means that the type and value must be the same
2, the value of the same type must be the same, but the ID may be different, as follows:
>> a= "Help:20"
>> b= "Help:20"
>> ID (a)
4330224472
>> ID (b)
4330224528
>> A = = b
True
>> A is B
False
>>
Constant
Constants refer to constant quantities
V. User interaction with the program
In the Python3
Input: The user enters any value and is stored as a string type
In the Python2
Input: Type of user input, what type is stored
Raw_input: equal to Python3 input
Comments
Single-line comment with #
Multiple lines of comment with "" "or" "" ""
VI. Basic data types
int integral type
For identification: Age, Grade XXX, QQ number, number
On a 32-bit machine, the number of integers is 32 bits and the value range is 231~231-1, which is -2147483648~2147483647
On a 64-bit system, the number of integers is 64 bits and the value range is 263~263-1, which is -9223372036854775808~
Float floating point number
Used to identify: salary, height, weight
Long (length integer) # (Understanding section)
Unlike the C language, Python's long integers do not refer to the positioning width, that is, Python does not limit the size of long integer values, but in fact, because of limited machine memory, we use a long integer value can not be infinite.
Note that, since Python2.2, Python automatically converts integer data to long integers if an integer overflows, so it does not cause any serious consequences if you do not add the letter L after long integer data.
Note: There is no longer a long type in Python3, all int
Complex plural type (understand)
String
In Python, the quoted character is the string type, and Python does not have a character type
Definition: name= ' user ' #name =str (' user ')
Getting Started with Python