P3 FlowControl
P3 FlowControl
e.g.
a = 8;
e.g.
a = a + 8;
相當於
a += 8;
if (y<>0): if (y<>0):
if (x/y>=0): if (x/y>=0):
f=sqrt(x/y) f=sqrt(x/y)
else: else:
f=sqr(x+y) f=sqr(x+y)
else:
print(fn1)
name it c0;
if it's even, evaluate a new c0 as c0 ÷ 2;
if c0 ≠ 1, skip to point 2.
or
iff P is true => P or Q is true without evaluating Q
ps:
0, 0.0, empty string、empty list, empty tuple、empty
container, None 都視為 False
versus
bit = i & j # 6
powers of two
[1, 2, 4, 8, 16, 32, 64, 128]
e.g. odds = [x for x in squares if x % 2 != 0 ]
makes a list with only the odd elements of the squares
list.
廖文宏 Python Programming 41
3.7.1.2 Multuple Dimension List
two dimension list, e.g.
board = []
for i in range(8)
row = [0 for i in range(8)]
board.append(row)