Statements, expressions and if the branch

First, the style code
1, code format guidelines
(1) PEP8
(2) 4 space indentation
(3) line of less than 79
(4) blank line
two, the assignment statement
1, the basic assignment
2, assignment sequence
3, the spreading sequence unpacking assignment
* variable represents the acquisition of the remaining elements to list

E.g. = S 'Hello World'
A, B, c * S = A #, B assignment sequence, all under c behind the rest of
the results returned to a = hb = ec = [ ' l', 'l', 'o ',' ',' W ',' O ',' R & lt ',' L ',' D ']
a, B *, C = S # a, C corresponding to the first and last string, the remaining full normalization b
results returned to a = HC = DB = [ 'E', 'L', 'L', 'O', '', 'W', 'O', 'R & lt', 'L']
b = ''. join (b) # join function with the list into a string
returned as the result worl ello
S = 'UKE'
a, B, C, D = S *
result is returned as a = ub = kc = ed = [], d is the empty list
4, multiobjective assignment
a = B = []
print (a, b) returns the result as [], []
a.append (2)
results print (a, b) is returned [2], [2]
a, B = [], []
a.append (6)
results print (a, b) returns to [6], []
5, the augmented assignment
a, b = 2,3
a + = b # a = a + b, a return value of 5
III expression
1, the function call
len ()
2, method call
3, literal
4, the printing operation
Print ()
(1) On Sep = 'separator'
(2) End = 'terminator'
(. 3) File = specified file
IV flow control
1, IF ... statement
(1) general format
IF ...:
Print ()
the else:
Print ()
(2) multiple branches
IF ...:
Print ()
elif:
Print ()
the else:
Print ()
(. 3) ternary operator X-IF the else the Y = A the Z
Result = 'pass' if score> = 60 else' failed'

Released eight original articles · won praise 0 · Views 122

Guess you like

Origin blog.csdn.net/DAN_L/article/details/104086402