def to define a function once, then call it anywhere:
def make_tree(scene, x, z): — define the steps oncemake_tree(scene, -3, 0) — place a tree with a single lineif condition: followed by an indented body
if y < 0: — reset a falling ball when it hits the groundif size > 3: — shrink a sphere when it grows too large< > <= >= == !=for i in range(10): — runs the body 10 times, i goes 0 → 9i to vary position, size, or color on each passwhile height < 5: — keep stacking boxes until the tower is tall enoughfor when you know the count, while when you don’trandom module makes scenes feel alive and unpredictable
random.randint(1, 8) — a random whole number between 1 and 8random.uniform(-8, 8) — a random decimal anywhere in a rangerandom.choice(colors) — pick one item at random from a listExplore the “Custom Functions”, “If Statements”, “For Loops”, “Random Numbers”, and “Let’s Experiment” notebooks
Ask for help if you need it!