Conditions, if statements, loops.
Conditions True # boolean True (capitalised) False # boolean False (capitalised) x > 3 # True if x is greater than 3, else False x < 3 # True if x is less than 3, else False x == 3 # True if x is equal to 3, else False x >= 3 # True if x is greater than or equal to 3, # else False x <= 3 # True if x is less than or equal to 3, # else False x !
Read more →
If you learn better by example, or if you are learning Python and you still need the odd reminder, try these cheatsheets.
Core Python Expressions and data types | Lists and tuples | Flow control
Read more →
Numbers # # Types of numbers # 5 # -> 5 (integer) type(5) # -> <class 'int'> # integer type 2.5 # -> 2.5 (float) type(2.5) # -> <class 'float'> # floating point type 10**100 # -> 10000000000000000000000000000...000 # eg 10 to the power 100 is 1 followed by 100 zeros # integers can have any number of digits, 1/3 # -> 0.3333333333333333 # Floats have around 16 significant figures 2+3j # -> (2+3j) (complex number, j represents # imaginary number) type(2+3j) # -> <class 'complex'> # complex number type Maths # # Operators # 2 + 4 # -> 6 (addition) 7 - 3 # -> 4 (subtraction) 6 * 2 # -> 12 (multiplication) 5 / 2 # -> 2.
Read more →