Chapter 1 | Getting started with Variables and Values
Built-in functions
● print() → Outputs its argument to the screen.
● sum() → Sums up the numbers in the list.
● input() → Takes user input and returns it as a string.
Keywords
● Argument → Object you put in a function
● String → A sequence of characters
● Comment → Used to document our code and explain what’s happening
● Variable →
● Value →
● Re-assign a variable → The value of a variable changes
Calculations
● Summing → print(3+2)
● Subtracting → print(7-1)
● Multiplication → print(3*3)
● Division → print(10/3)
● Power → print(5**2)
Additional theory - Naming variables
1. Use clear, meaningful, descriptive variable names so that your code will remain
understandable.
2. Use the lowercase_with_underscores style, with lowercase characters and underscores
for separating words
3. Do not use built-in names, such as print or sum (these will turn green in Jupyter
Notebooks)
,Chapter 2 | Basic Data Types (Integers and Floats)
Built-in functions
● type() → To check object types.
Methods
● int() → Converts any number or string into an integer object.
● str() → Returns the string version of the object.
Keywords
● String → For representing text.
● Integer → For representing whole numbers.
Float → For representing numbers with decimals.
● Tuple → For representing immutable combinations of values.
● List → For representing ordered sequences of objects.
● Set → For representing unordered sets of objects.
● Dictionary → To represent mappings between objects
● Booleans → To represent the truth values True or False.
● Casting → Converting one type into another type.
● Coercion → Implicit type conversion. For example when you divide 2 integers with
each other the output is a float.
● Operator precedence → The order in which mathematical operations are performed.
Additional theory - Type affordances
It is possible to use “+” for adding up integers and floats. It is also possible to add strings
together. However, it is not possible to add strings and integers/floats up. Python will then
give an error.
Casting types
Not all conversions are possible. For example, we cannot make an integer of the string
“hello”.
,Mathematical operators
, Chapter 3 | Strings
Built-in functions
● repr() → Gives you the Python-internal representation of an object.
● len() → Lets you compute the length of a sequence. (spaces count as characters
too!)
● dir() → Returns a list of method names (as well as attributes of the object).
● help() → If you want to know what a specific method does.
Methods
● str.lower() → Turns a string into all lowercase characters
● str.upper() → Turns a string into all uppercase characters
Keywords
● Index number → The position of a character in a string. Positive index starts at 0.
Negative index starts at -1 and goes backwards.
● Mutability → Whether an object can change or not.
● Immutable → an object cannot be changed.
● f-strings → New string formatting mechanisms that make string interpolation
simpler.
● Method → A function that is associated with an object.
● Dunder methods → Method names that start and end with double underscores. They
are Python-internal.
Additional theory - Multi-line string
Two ways to span strings across multiple lines:
1. With single or double quotes, where we manually indicate that the rest of the string
continues on the next line with a backslash
→ \n (newline symbol) indicates that we want to start the rest of the text on a new
line in the string, the following \ indicates that we want the string to continue on the
next line of the code. Together ( \n\ ).
2. With three single or double quotes.
→ Another way to span strings across multiple lines is by simply using three single or
double quotes.