You've got the eight bricks. This sheet is the next course — the pieces that turn a script into something that remembers, asks, borrows tools, and doesn't fall over when something goes wrong.
Lists are numbered — but counting starts at 0, not 1. You can also tack new items onto the end.
crates = ["A", "B", "C"] print(crates[0]) # -> A crates.append("D") # now A B C D
A dictionary stores things by name instead of by position: a key points to a value.
stock = {"apples": 12, "pears": 4}
print(stock["apples"]) # -> 12
stock["pears"] = 9 # update it
An f"..." string lets you drop variables straight into a sentence using {curly braces}.
name = "Dick" n = 128 print(f"{name} has {n} orders") # -> Dick has 128 orders
input() pauses and waits for the person to type. It always hands back text, so wrap it in int() for numbers.
naam = input("Je naam? ") leeftijd = int(input("Leeftijd? ")) print("Hallo", naam)
A while loop keeps going as long as its condition stays true — handy when you don't know the count in advance.
n = 3 while n > 0: print(n) n = n - 1 # -> 3, 2, 1
import pulls in code other people already wrote, so you don't reinvent it.
import random pick = random.choice(crates) print("Chosen:", pick)
try / except lets you attempt something risky and catch the fall instead of crashing.
try: total = 10 / 0 except ZeroDivisionError: print("kan niet delen door nul")
open() with with lets you write to (or read from) a file on disk, then tidies up after itself.
with open("notes.txt", "w") as f: f.write("hoi Dick") # file now holds: hoi Dick
Borrow a tool, look something up by name, and slot it into a sentence — three of the ideas above in five lines:
import random stock = {"apples": 12, "pears": 4, "plums": 7} fruit = random.choice(list(stock)) print(f"Picking {fruit}: {stock[fruit]} left") # -> Picking pears: 4 left