CS111 Course Intro: Drawing Tinman

Note: To run the code in a cell, select it (by putting the cursor in the cell) and then click the Run button. (It looks like Play in a music player interface). Alternatively, press Shift+Return in your keyboard.

Let's now have some fun drawing with Python

This example is just a preview into what you can do graphically with Python. Don't panic if the code seems opaque. It will become a lot clearer once we go through it.

Step 1: Import Turtle Graphics

The first thing we need to do is import a package named turtle that allows us to generate images.

You can find documentation on turtle graphics here.

The CS111 team has also developed another package that makes drawing simple and concise. Make sure turtleShapes.py is in the same folder as this notebook. Go ahead and import that as well.

Step 2: Setup the Turtle Screen

Before we draw our picture, we generally want to setup our turtle. Simply execute the code below. We will learn more about what exactly this code does in the coming classes.

Step 3: Draw the parts of Tinman one by one

First we will draw the head. Executing the code below should pop up a graphics window where you can see a circle being drawn on the screen.

... and add the rest of the body

You can also add text to your picture as well.

Step 4: Clear the Screen (Optional)

If at any point, you want to clear the screen and start over run the code below.

That's all for now! We will do much more with turtle graphics over the course of the semester.