| title | Fractals |
|---|---|
| subtitle | Functions and Recursion in Scratch and Python |
| revealjs-url | ./lib/reveal |
| theme | fractals |
| transition | slide |
::: incremental
- Welcome to CoderDojoDC
- Welcome to the Maryland STEM Festival
:::
Fractals are shapes with some special characteristics:
::: incremental
- Fine Structure
- Self-Similarity
- Scaled Symmetry
- Recursion
:::
To make a fractal, start with a basic shape or line
You then repeat the same line in each of the parts of the original
As you continue to repeat, or recurse downward, the shape becomes more intricate
In order to draw fractals with computers we use two things:
::: incremental
- Functions: Functions are like little recipes
- Recursion: Recursion is when a function "calls" itself
:::
To draw a fractal in Scratch, we can use the following:
::: incremental
- Pen Tool
- Custom Blocks (functions)
- Recursion (putting a custom block inside itself)
:::
A Fractal Project on the Scratch Website
import turtle # imports the turtle module
t = turtle.Turtle() # creates a turtle
t.forward(100) # draws 100 pixels forward
t.left(60) # turns left 60°
t.forward(100) # draws 100 pixels forward
t.right(120) # turns right 120°
t.forward(100) # draws 100 pixels forward
t.left(60) # turns left 60°
t.forward(100) # draws 100 pixels forward
turtle.done() # keeps the window open
- See if you can change the Scratch project to draw your own shapes
- If you want to try Python, have a look at the examples



