LANGUAGE » PYTHON
Syntax
Comment
python
## Single line comment
'''
Multi-line
comment
'''
Variables
python
my_int = 7
my_float = 1.234
my_bool = True
my_string = 'I\'m new here!' # May be used as array
my_array = [1, 2, 3, 4]
my_dict = {'name': 'John', 'age': 28}
Simple operations
python
addition = 72 + 23
subtraction = 108 - 204
multiplication = 108 * 0.5
division = 108 / 9
exponentiation = 10 ** 2
modulo = 10 % 2
Bool evaluations
python
100 == (2 * 50) and 19 <= 19
-22 >= -18 or 99 != (98 + 1)
not False
Unlike other programming languages, comparison operations can be chained.
python
1 < 2 < 3
Function
python
def spam():
eggs = 12
return eggs
lambda (parameters): (return expression)