
Generally speaking, python is pre-installed on linux. As long as you enter python in Bash Shell, you can see the following version information:

Press Ctrl+D or execute the command exit(), you can exit python.
If you want to check if python3 is installed, you need to type python3 in Bash Shell.
.py file, .py is the default suffix for python source filesPrint ("Hello World!") // print is a function in python3,
so be enclosed in parentheses
and then save it as first.py.
Enter Python first.py on the command line to view the script running results.
Download the interpreter python2 or python3 on the http://python.org/downloads/ page first, and be sure to select Add Python to Path when installing, so that the environment variables are automatically added, which will make it more convenient for you to use python.
.py filesFirst of all .py file states that this is a Python source file. The Python interpreter then runs this file. The Python interpreter reads every word throughout the program to determine its meaning.
This is the biggest difference between Python and C++, C++ is a strongly typed language, each variable requires a certain type, that is, C++ variables must be declared before use, but the type of variable in Python depends on the type of the value it is bound to, that is, in Python, the variable must be initialized immediately when defined, otherwise, the type of the variable will not be known. The definition of a Python variable is similar to Atuo X = 1; the type of X is automatically derived from the right value of the expression 1, but the difference is that in Python code, you can modify the value of the same variable anywhere, but if the type of the value on the right side of the expression assigned to the variable is different from the previous time, then the type of the variable binding is the type of the new value, which means that Python always remembers the type and value of the latest value of the variable. For example:
message = 2 //The type of message is integer. print(message) message = "Hello World!" //The type of message is a string. print(message)
When the interpreter executes the program, if an error occurs, the interpreter will provide a traceback, which is a record indicating where the interpreter encountered an error when running the program.

For example, the above result shows that when the interpreter is running the program, an error occurred when the print module was last called on line 2 of the test.py file, and the error was: the variable name 'mesage' is not defined. The print (mesage) indicates the code that has an error, which is intended to help you quickly find the error code. A NameError usually means two problems, one is that the variable is not defined, and the other is that the variable is not assigned a value before using it.
In addition, unlike C++, python does not use a semicolon as the end of a statement, but a newline character as the end mark of the statement.
Use uppercase and lowercase letters and underscores with the suffix of .py.
If:The core of the if statement in Python is an expression with the values of True and False, for example:
If expression:
Statements