Most of the existing Python tutorials are generally a brief introduction to the usefulness of Python, and then began to talk about data structures, control flow, file input and output, exceptions, and so on some completely do not understand what is the programming language of friends, it will be difficult to quickly enter the state. So this article mainly wants to introduce what is the programming language and the main component of Python, so that everyone in the process of learning Python will not feel confused. With such a big frame, it's like a map when playing a game, so that everyone knows where they are at each step of the learning process and where they are.
1. Definition of programming language
According to Wikipedia, programming languages are the formal language used to define computer programs. It is a standardized communication technique used to give instructions to a computer. For example, if a Chinese people want to communicate with an American, will choose to use English to communicate, so that both sides can understand each other, then human to communicate with the computer, what language should be used? This language, as we call it, is a programming language.
2. Low-level and high-level languages
We know that the computer can only understand the binary, that using the binary to send instructions to the machine is the machine language (binary language), which is the most basic language, the machine executes the fastest, but for us humans, if you want to tell the calculator to load by 0000来, Use 0001来 to tell the computer to store, and even according to the number of computer processor bits to change instructions, but the brain to explode. Therefore, the assembly language (assembly language), assembly language is the text form of the binary instruction, and the instruction is the corresponding relationship one by one. For example, the addition instruction 00000011
written in assembly language is ADD. Assembly languages are slightly understood than machine language, but still closer to the machine's understanding model than to human understanding. These languages we call low-level language, because humans are more difficult to understand. After this, for different applications, different purposes, in order to make it easier for humans to learn and write programs, people put forward thousands of advanced programming languages (High level language). The more mainstream high-level languages have c,c++,c#,java,python,perl,html,javascript,objective C and so on. C is mainly used to write the operating system, Java is mainly used to write servers, big data, Android app development, HTML to write Web pages (HTML does not seem to count as a language). These languages are more like English grammar, so it is easier for humans to understand and learn. Python is a bit more advanced than C and C + +, which is closer to human understanding and easier to learn.
3. Composition of Python
The purpose of the programming language mentioned above is to define a computer program that allows the computer to perform some of the actions we want him to perform, so they all have some common parts, that is, that almost all programming languages require. Data structures, input and output, exceptions, process controls, standard libraries, and extension libraries are the main factors.
So what are the roles of these components in a project? I have drawn the following diagram:
This picture, we look out from the inside, in the innermost is a diagram similar to a flowchart, the first is the input, usually a program always need to deal with something, such as a request from the network, such as crawling down from the Web page, such as data from the database, such as the data from the databases, such as a picture, For example, the data read from the file, such as user input simple name or number, and so on. This is usually the first step of a program to get these inputs, and then we need to store this data in a container-data structure. The data structure is used to store the memory units, Python mainly has three major types of data type, the first class is the basic data type (basic information type), that is, the number and string, the second class is the Python built-in data structure, namely the list ( List), tuple (tuple), and dictionary (Dict); The third class is class. I think the three types of relationships are classes that can include List,tuple,dict,number and string, while elements of list,tuple and Dict can consist of number and string, which can actually be an object, an instance of class. There is a feeling of complementarity between the three. After the data is stored, we will need to do a series of calculation operations, which will usually need to do different operations for different inputs, or do the same operation many times, this time requires process control, Python's process control mainly includes the If/else, while, the for As well as the two auxiliary continue and break. When the operation is completed, we can show this result, this step is output, you can output to the GUI to display a graph or a number, you can write the file to the user later use, you can return the network request to the client, and so on. This is usually the process of a program. Then we also know that in the process of running the program may appear some of the problems we did not anticipate when writing the program, when encountering these problems, we may want the program does not directly crash, but can output some information to suggest that we have a problem, or do not crash to do a second attempt, etc. , Python provides a exception class to categorize most of the existing exception, and provides try/except to allow the user to handle the exception. This is almost all the process of a program.
So we can use the list Tuple dict and so on, instead of using binary or assembler to represent the data structure we want, because Python provides the standard library, which is also the standards libraries. This standard library defines the first two types of data structures that we have just mentioned, defining many of the operations that are used daily, such as searching for strings, checking for casing, split, and so on, such as for mathematical conjugate numbers, exponentiation, and so on. With this library, we can write programs more easily without having to define some common and basic methods from scratch.
In addition to the standard library, many developers have developed a number of useful and stable third-party libraries, such as Pandas,sqlalchemy, and so on, these libraries can help you develop faster and better. Standard libraries and third-party libraries provide support to all developers and are an integral part of the development process.
The above is my understanding of Python and programming language, if there is a problem, please criticize correct.
Python Tutorial--programming language