< Back

Lab 2: More Turtle

The one drawback to this type of course is that we have to dive head-first into some programming features much earlier than other types of CS courses. However, since we are using Python, it's not as complicated as it may seem at first. Today, we will introduce functions and loops, so we can start doing more interesting, media related stuff very soon.


Star Field

In a file called StarField.py, create a program that draws at least 10 stars on a turtle window. These stars must all have differing sizes, and must not overlap at all.

To accomplish this, you should write a function called draw_star(turtle, x_loc, y_loc, size), which draws a star using the given turtle at the specified location, at the specified side length.


Polygons

In a file called Polygons.py, write a program that is able to draw arbitrary polygons to the turtle window. To accomoplish this, you should write a function called draw_polygon(turtle, x, y, , num_sides) which takes an x and y coordinate and the number of sides to draw the shape. It should use the provided turtle to draw the shape in the specified location.

4 sides: 6 sides: 15 sides: