Drawing Fractals
Concentric Circles
First, write a recursive function that draws concentric circles, like this:
To start you can use the following program which draws one big circle at the center of the screen big_circle.py.
Change this program so that instead of drawing one big circle, it calls a recursive function which draws concentric circles as in the picture.
In the recursive case (if the radius is greater than some threshold), this function should draw a circle at the given radius and then call itself recursively with a smaller radius.
In the base case (if the radius is smaller or equal to some threshold), this function should just draw a circle.
Write the code on paper first, then implement it.
More circles
Next, write a program that recursively draws this picture:
Figure out what the recursion is, first, and describe it in English. Then, write the code on paper, and only then implement it.
Pyramid
Here is another one to try. If you prefer you can also invent your own recursive pattern and write a program that draws it.
Left is a picture of the whole pyramid. The picture on the right shows a close up of the smallest piece - so you can see that the pyramid is built of squares, even though it may look triangular.
Invent your own
Invent your own recursive pattern and write a program that draws it.