Prelab 2 Due: Beginning of lab on 2020-02-21

For the lab this week, we will be using the turtle graphics module to draw a picture. You will have two options, a seascape with fish and rocks, or a space scene with spaceships and planets.

The turtle module

An important programming paradigm is code reuse. Rather than writing your own code, say a turtle module, you can use one that someone has already written. An important part of programming then is documentation, both reading documentation and generating it for your own programs. The documentation for the turtle module can be found at http://docs.python.org/3/library/turtle.html, and contains an overview of all of the functions available to you.

To get ready for lab you’re going to need to read a bit more about some of the functionality of the turtle module. Below are a few methods that may be useful, but that we haven’t focused on in class. Click on each of them in the documentation and make sure you understand what they do as well as what parameters they take and what, if anything, they do or return.

In addition to looking at the online documentation, also try out the help function, which takes the name of a function as an argument, and outputs the docstring (i.e. function description) for us. Start up Thonny and use help to get the documentation for some of the above two functions. Remember you will need to import the turtle module first:

from turtle import *

Here are some more example functions using turtle for you to review in preparation for lab.

Planning your drawing

Read through this whole section before starting on your drawing. For fish or spaceships, we will use a triangle function and for rocks or planets, we will use arbitrarily sized polygons.

Plan out the design for your drawing on paper. The screen size will be about 700 x 700 (each dimension ranging from -350 to 350, with the origin (0,0) in the center of the window). You will submit a copy of your hand-drawing using a sheet of paper we distribute in class.

With these dimensions in mind, plan out on the paper where the different shapes will go, their sizes, etc., In particular:

As part of your planning, start thinking through how you will draw your shapes and how that approach influences your choice of coordinates, etc. For example, when you specify the coordinates of a triangle, which corner of the triangle do those coordinates specify?

You should plan on having at least six fish/ships and six rocks/planets (though if you’d like to have more, that’s fine too).

Bring your hand-drawn plan with you to lab – we will collect it briefly and then return to you to use in creating your drawing.