1. Variables
Variable: the intermediate result of the operation to the temporary memory, for subsequent transfer Using procedures.
Direct operation, as follows:
print(3+5+6) print((3+5+6)*12) print(((3+5+6)*12)+3) print((((3+5+6)*12)+3)/45)
Variables may be used, as follows:
=. 5. 3 + + a. 6 # where a is a variable. a temporary recording value for the latter to continue the program execution using the Print (* 12 is a)
The variable can store the value of various types, as follows:
= A " Alex " Print (A) A = 23 is Print (A) B = A # sequentially. The value assigned to the right-hand side of the left operand Print (B)
Variable naming rules:
1. letters, numbers or underlines
2 can not be purely digital. Not begin with a digit
3. python keyword is not
4 not too long
5. To meaningful
6. case sensitive
7. Do not use Chinese ( specification)
8. recommended hump or underscore named
2. Constant
Absolute constants do not exist in python. Convention, all capital letters is constant.
E.g:
PI = 3.141592653
BIRTH_OF_SYLAR = 1990
3. Comment
Sometimes we write something not necessarily to the user to see, or do not need an interpreter to perform, then we can use # to comment out the code, programmers can easily be behind the content of the comment will not be implemented read your code.
Single-line comments: # annotated content
Multi-line comments: '' 'is the content of the comment' '' '' 'This is a multi-line comments "" "
4. The basic data types