Python definitions
Python variables are defined as
x = 42 s = 'abc' pi = 3.14
Python functions are defined as
def convert(f): return 5/9 * (f-32)
- There must be an explicit
returnto return the result. - Note also how the body of the function is indented.
- There must be an explicit
returnreturns andprintprints.def add3return(n): return n + 3 def add3print(n): print(n + 3) 7 + add3return(5) 7 + add3print(5) # fails!