CS 150 - Prelab 2

Due: Friday 2/24 at the beginning of lab

For the lab on Friday, 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 (talk to me if you have an idea of another scene type that uses similar shapes).

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 coding then is documentation, both generating it for your programs and being able to understand other people's documentation.

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 on Friday, 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 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 Spyder and use help to get the documentation for some of the above two functions. Remember you will need to import the turtle module first by typing
from turtle import *

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. For example, here is an example seascape:

On a piece of paper (ideally graph paper) plan out the design for your drawing. The screen size will be about 700 x 700 (each dimension ranging from -350 to 350). The origin (0, 0) is in the center of the window, and the y-axis points UP as usual, so (350, 350) would be the top right corner of the drawing window.

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

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 this finished plan to class on Friday. I will check the plans at the beginning of class.

Eventually, we'll add bubbles/stars to make it look more interesting, but we'll deal with that on Friday (though I've included an example below so you'll see what the finished product looks like).