What is Python?
First of all, we introduce the Python language, Python is an explanatory scripting language, it does not need to be compiled and executed like C + +, nor can it be executed directly on the browser like JS. It provides us with a basic codebase that covers a wide range of content such as networks, files, GUIs, databases, text, and so on, and you can directly use the functionality provided by Python without having to start writing again. Python can be used in various fields, such as server development, GUI, data mining and so on. And so on want to know more friends, can self-degree Niang down bar.
Once we know the language of Python, we also need to make a brief introduction to its language features.
The basic rules of Python are this:
1. The character after the pound sign (#) is a comment, and the comment does not affect the code;
2. Usually one line of statements;
3. If a statement line does not fit, you can use a backslash (\) to continue on the line;
4. Semicolon (;) Two statements can be concatenated in one row;
5. Colon (:) separates the head and body of the code block;
6. Different indentation depth (space) separates different blocks of code;
7. Python files are organized in the form of modules.
In this case, we think the most important point is the indentation of Python.
Python differs from many other programming languages in a number of details, which can be said to be ingenious and distinctive! Of course, the most important thing in this area is the indentation of Python! In the Python world, the number of spaces indented is variable, but the indentation of all the statements in the code block must be strictly consistent or the program cannot execute.
Because indentation is important for Python, it is used to identify different blocks of code and to determine the relationship between lines of code through different indentation. Indentation is not mandatory, but it is recommended that the code context use the same size indentation. And python suggests using spaces to indent, rather than tab, because different editors in different environments have almost the same logic for the display of spaces, but there are a variety of tabs.
Let's look at two pieces of code to deepen our understanding of indentation:
Code snippet A
Weight = 60
If weight > 70:
Print (' You are overweight ')
Print (' Science Diet ')
Print (' Care for health ')
Code Snippet B
Weight = 60
If weight > 70:
Print (' You are overweight ')
Print (' Science Diet ')
Print (' Care for health ')
What do you think the output of the two pieces of code is?
Answer: http://www.mayacoder.com/lesson/lesson?lesson_id=56&knowledge_id=4
The code experience goes to the link above, and the results are as follows:
Beginner of Python Learning basics python--Unique 1