Control
Expressions evaluate to values
Statements perform actions
print(print('1'), print('2'))
1
2
None None
Boolean Expressions
T and F
False values: False, None, 0, ‘’
True values: everything else
Operators
and, or, not
True and 5 + 2 and 8
8
False or print('hi') or True
hi
True
False or True or print('hi')
True
While statements
def fib(n):
cur, nxt = 0, 1
k = 0
while k < n:
cur, nxt = nxt, cur + nxt
k += 1
return cur