python

type()

To get the type of any object use type().

x = 4
print(type(x))

Variables and parameters are local

Variables and parameters inside a function exist only inside that function.

Modules

A module is a file containing python commands such as the math module or one created by yourself.

import math

Expressions and Statements

Expressions can be printed whereas statements cannot.

x+5 #expression
y=x+5 #statement

Recursion

Recursion is when a function calls itself, e.g.

def countdown(n):
  if n <= 0:
    print(' Blastoff!' )
  else:
    print(n)
    countdown(n-1)

Infinite recursion is generally not a good idea

def recurse():
  recurse()

Python will report an error message when the maximum recursion depth is reached:

>>>RuntimeError: Maximum recursion depth exceeded

list vs tuple

keywords vs built-in functions

f strings