turtle
module. Create a directory called graphicsintro
that will
hold all of your work for this
assignment.
Save the my_artwork.py
module into your graphicsintro
directory, and open it up.
Read through the code and see if you can figure out what it will do.
Start a terminal and open a Python interpreter. At the Python
prompt, type as follows:
>>> import my_artwork
>>> my_artwork.drawpic()
What do you see?
Write a Python program named drawing.py
. Your program
should create a
Turtle object and use the methods in the book to draw a picture.
Put the code that does this drawing inside a function named drawpic
,
so your code can be run in the same way as the code is run in my_artwork.py
.
Spend a little bit of time experimenting with the different methods,
and
then figure out how to combine these methods to draw more complex
shapes
or pictures.
Some ideas:
Combine simple shapes in more complex ways. For example, combine triangles to form a star, or circles to generate different patterns, or rectangles to create a tic-tac-toe board.
Use loops to perform repeated tasks.
Use the time
module for animation as follows. Add the line import time
to the top of your program. This
gives you access to the sleep
function, which will force Python to
wait a
certain period of time. For example, time.sleep(5)
will
make Python wait 5 seconds.
Be creative, and have fun!
Submit one file, drawing.py
,
using the turnin form.
Created September 12, 2016
Last revisedSeptember 12, 2016, 02:21:07 PM PDT
This work is licensed under a Creative
Commons Attribution-Noncommercial-Share Alike 3.0 United States License.