You have now been briefly introduced to two very powerful constructs in the Python programming language: for loops and functions. Today, we will try to solidify your understanding of these topics, and exploring more of what Turtle lets us do.
In a file called Polygons.py, write a program that is able
to draw arbitrary polygons to the turtle window. To accomplish
this, you should write a function called draw_polygon(x, y,
num_sides)
, which takes an x and y
coordinate and the number of sides to draw
the shape. It should use turtle to draw the shape in
the specified location.
In a file called Spirograph.py, write a program that mimics
the Spirograph devices that you likely remember from your
childhood. Your program should have a function
called draw_spirograph(side_length)
, which takes 1
integer as a parameter. It
should use the information passed to the function to draw a spiral shape
with the specified length of a side. Your Spirograph can have as
many points as you wish, but it must contain more than 10, and have
some circular space in
the center that is empty.