First, the input and output
Print ( "String " ); Print ( " string1 " , " string2 " , " string3 " ); // comma will be reflected in the form of a space Print (NUM); name = input();
Second, the basic format and annotation
1, #
sentence beginning of the Notes, the interpreter will ignore the comment.
2, every other row is a statement, the statements colon :
at the end, indented statement as code blocks .
Indent both advantages and disadvantages. Benefit is forcing you to write code formatting, but no provision is indented a few spaces or Tab. By convention management, you should always stick with the four spaces of indentation.
a = 88 if a >= 0: print(a) else: print(-a)
Third, the data type
1, integer
Hexadecimal with 0x
the prefix and 0-9, af represent
2, floating point
Scientific notation, the 10 replaced with E, 1.23x10 . 9 is1.23e9
3, strings
(1) '' or '' string is enclosed
(2) escape character '\'
A, escape character \
can escape a lot of characters, such as \n
newline, \t
tab character, the character \
itself must be escaped, it \\
represents the character is \
,
B, if there are many character strings need to be escaped, you need to add much \
, for simplicity, Python also allows r''
represented by ''
the string does not escape the inside of the default
C, if the internal string has a lot of line breaks, with \n
write one line is not good reading, in order to simplify, Python allows '''...'''
format represents a number of lines
4, Boolean
Ture or False
and or not operational
5, null
With None
representation
Fourth, variable
1, the variable itself is not fixed type of language called dynamic languages, Python language used
2, understand variable assignment, Python do the methods of operation
a = 'abc';
Python interpreter did two things:
-
Created in memory of a
'ABC'
string; -
We created a directory named in memory
a
variables, and it points to'ABC'
.
3, constant, does not require const, usually defined constants in all uppercase way
4, the difference division
(1) / floating point arithmetic operation results
(2) the calculation result is divisible //
(3) to take the remainder arithmetic%
Reproduced in: https: //www.cnblogs.com/BlueMountain-HaggenDazs/p/6148868.html