You can begin either with a starter project at CodeHS that uses Python's Turtle module, or with a starter project at CodeHS that uses my Euclid module. (They are also at GitHub - the Turtle version here and the Euclid version here.) I find that the Euclid module runs a bit faster and produces images that look a bit better. The primary difference between the two modules is the coordinate system used. In Turtle: (0, 0) is in the middle of the window, and the second coordinate increases as we go up. In Euclid: (0, 0) is the top left corner of the window, and the second coordinate increases as we go down.
The documentation for the Turtle module resides at python.org. The documentation for the Euclid module is here at Think Functional!.
Modify the code (or write your own code from scratch - I don't care) so that it draws Sierpinski's Carpet. (I'll let you Google that.)
Requirements:
Iterate through the first six carpets as my code iterates through the first six triangles.
As you work through the recursive levels of a given carpet, change the pen color. Make it pretty!
Extra Credit:
Do Sierpinski's Pentagon.
Extra Extra Credit:
Write me a higher-level function named sierPoly (short for "Sierpinski's Polygon") that has an additional parameter n for number of sides and will draw, for any n, the Sierpinski object with n sides. So for n = 5, it will draw the Sierpinski Pentagon; and for n = 6, it will draw the Sierpinski Hexagon (again Google). Etc.
When I hit run, your program should draw the Sierpinski Carpet for n = 1. It should then pause for a second, clear the screen and the draw the Sierpinski Carpet for n = 2. It should continue on in this way until n = 6. The n = 6 version should be left on the screen once the animation is complete.