Name is based on Monty Python.
Created by Guido van Rossum in the late 80s.
Dynamically typed. Supports optional type hinting.
a = True
a = False
Use snake case. Only special character allowed in variable names is an underscore. Can’t start with a number.
Strong literals can use either single or double quotes:
"hello world"
'hello "world"'
'sam\'s birthday'
"multiple " \
"lines"
Common operations:
len("hello world") # can also be used on non-strings
"Hello World".lower()
"Hello World".upper()
"he" + "l" * 2 + "o"
"strings need to be concatenated with strings" + str(1)
"a formatted string %s %s" % (str1, str2)
F strings:
name = 'world'
s = f'hello {name} {1 + 2}'
Basic operations:
sum = 1 + 2
float_fraction_number = 2 / 3
int_number = 2 // 3 # result is 0
power = 2 ** 3 # 2^3
remainder = 11 % 10