Sierpinski's Carpet
Sierpinski's Carpet
The script linked below draws the Sierpinski Triangle. Modify it (or write your own code from scratch - I don't care) so that it draws Sierpinski's Carpet. (I'll let you Google that.) Note that it makes use of Python's Turtle Module. So if you're at replit, you should create a Python (with Turtle) repl. The documentation for the Turtle Module resides at python.org.
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.
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.