Variable: You can change its state arbitrarily by assigning a value. Variables typically store changes or states in the execution of a program.
Format:
Variable name = variable Value
If you have a string type, you need to add the ' value '.
Example: Name= ' Xuzuo '
Age=18
The type of your value is automatically detected when you assign a value. You can also view the type of a value by type (variable name).
Example: Print (type (variable name))
Canonical definition of variable name:
1. Variable names can only be any combination of letters, numbers, or underscores
2. The first character of a variable name cannot be a number
3. Keywords cannot be declared as variable names (e.g. print break continue, etc.)
4. The assignment is best in English, close to the information you want to describe this value.
How to define:
Hump body Ageofxuzuo = Numberofstudents = 80
Underline (recommended) Age_of_xuzuo = Number_of_students = 80
Constants: There are constants in the variable, but there is no special format definition constants in Python. You can use all caps to represent constants.
(This method can be arbitrarily modified.) Just use uppercase to indicate "this is not easy to modify")
Comments:
With the depth of study, not long, you can write complex thousands or even tens of thousands of lines of code, some code you spent a long time to write, after some days to go back to see, it is too normal to read. In addition, you later in the work will find that a project is more than a few or even dozens of developers to do, you want to call someone else to write code, others will use yours, if the code is not annotated, you can not understand, let alone others, this production will be beaten. So in order to avoid this embarrassing thing to happen, be sure to increase the readability of your code.
Code comment split-line and multiline comments, single-line comments with #, multiline comments can be three pairs of double quotes "" "" ""
File header
#!/usr/bin/env python
#-*-Coding:utf-8-*-(with # coding:utf-8 no difference. )
Python Basics-Variables