Functions and Turtles

[et_pb_section][et_pb_row][et_pb_column type=”2_3″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left”]

In this unit you’ll learn about functions while using a fun graphics library called ‘turtle’.

1. Using the turtle library, make a drawing. Use at a minimum the following functions.

goto(x, y)

Each of these functions takes one or more parameters.  Make a drawing of a thing, not just an abstract drawing.   A house or a car would be appropriate.   This will show that you understand the turtle functions.    Save your drawing as

2.  Use a loop and the turtle drawing functions to make a design.  Use pen and fill colors.  Save your drawing as  Also make a document with a screenshot of your design and your code.  Make it all fit on one page and print it out in color.

3.  Write your own function, house( ) that draws a house!  Make it a small house so that you can fit multiple houses on the screen.   Then write a program that draws at least three of your houses on the screen.  You’ll have to move the turtle before you make the second and third houses.  You should probably try and avoid using the goto(x, y) or the setx() and sety() functions – if you try, you’ll see what happens!  It is possible to use them, but not easy!

4.  Write another function that uses parameters x and y to put a house anywhere on the screen.  Your function should be called house_at(x, y).  It should move the turtle to x, y and draw a house (right side up.)  Make a program, that draws at least three houses.   Its fun to use a loop and random numbers to put houses everywhere!


The turtle library lets you write interactive programs.  See if you can write a game that uses keyboard and/or mouse input.   I wrote a program I call “tictacturtle” that lets you play tic tac toe, with the turtle drawing the board.


[/et_pb_text][/et_pb_column][et_pb_column type=”1_3″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left”]Resources: The Python turtle library [/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]