This task is part of project01 which is due at 23:00 EST on 2025-01-28.
You have the option to work with a partner on this task if you wish. Working with a partner requires more work to coordinate schedules, but if you work together and make sure that you are both understanding the code you write, you will make progress faster and learn more.
You can download the starter code for this task using this link.
You can submit this task using this link.
Put all of your work for this task into the file
scene.py
(you will create this file from scratch)
Note: You can view a video walkthrough of these instructions if you prefer to hear them explained instead of reading them yourself.
For this task, we want you to get some practice writing code at the most
basic level, and also become familiar with the turtle
and turtleBeads
commands that can be used for drawing in Python.
The requirements are very simple, and in fact, there are no restrictions on what you draw: the only rules are that you must make use of certain functions.
To start, you need to create a new file, named scene.py
. This file must
be in a folder where turtleBeads.py
is also present. To create that
file, you should:
turtleBeads.py
.Now you're ready to write code. Your scene.py
file must satisfy the
following criteria:
Your file must start with a triple-quoted string at the top, identifying the names of each author, which classmates and/or tutors and/or instructors you consulted for help, the last date you modified the file, and a brief description of the purpose of the file. We will do this for all files that you submit in this class. Here is an example:
py
"""
Authors: Anon & Ymous
Consulted: T. A.
Date: 2022-9-8
Purpose: Turtle Scene task
"""
Your file must appropriately import
the turtleBeads
module. You
will also need to import the turtle
module separately to ensure that
you can use the basic drawing commands.
forward
(a.k.a. fd
)backward
(a.k.a. bk
or back
)left
(a.k.a. lt
)right
(a.k.a. rt
)
(this example provides a brief reminder of how
these work).setx
, sety
,
setpos
/setposition
/goto
, or
teleport
).turtleBeads
shapes
(turtleBeads
reference):drawCircle
(you may use the
turtle
function circle
instead)drawRectangle
drawText
(you may use the
turtle
function write
instead)pensize
and either
pencolor
or color
(pen
functions reference).begin_fill
and
end_fill
to draw at least one
filled-in shape, and you must use fillcolor
(or
color
)) to control its color
(fill reference; see also the
example on filling).penup
and
pendown
to move the turtle
without drawing a line (or you may use the one or more of the
teleport
, leap
, or hop
functions from
turtleBeads
to achieve the same
thing).title
function to
assign a title to your graphics window (title
reference).You are welcome to use other turtle
or turtleBeads
features in
addition to the ones listed above, but only the above features are
required.
If you want to challenge yourself and read ahead a little bit, consider defining a custom function and using it as part of your turtle scene (but you will not receive any extra credit for this, so don't do it if you're short on time).
Note: to speed up the drawing when things get complex, you can use the
noTrace
and
showPicture
functions. You can read
how they work in our turtle documentation.
After completing this task, you must take a screenshot of your graphics scene, name it correctly, and upload it to the shared google drive folder as explained in the submission instructions.
Using turtle
Here's a brief reminder of how to use the turtle
/turtleBeads
drawing commands. This code draws a triangle by drawing a line and then turning three times.
In []:Printsfrom turtleBeads import * forward(200) left(120) fd(200) lt(120) fd(200) lt(120)
A 1-pensize black horizontal line from (0, 0) to (200, 0). A 1-pensize black 120° line from (200, 0) to (100, 173). A 1-pensize black 60° line from (100, 173) to (0, 0).Image
Filling a shape
Here's an example of how to use begin_fill
and end_fill
together to fill in a shape, along with a few other commands to customize things. Remember that a quick reference guide is available that covers all of the turtle
and turtleBeads
functions we will use in this class.
In []:Printsfrom turtleBeads import * pencolor("SkyBlue") pensize(3) fillcolor("HotPink") begin_fill() drawCircle(120) end_fill()
Start of filled shape. A 3-pensize SkyBlue circle centered at (0, 0) with radius 120 Filled in shape using HotPink.Image
forward
forward
or fd
in at least one place.backward
backward
, bk
, or back
in at least one place.left
left
or lt
in at least one place.right
right
or rt
in at least one place.setpos
setpos
, setposition
, setPosition
, goto
, setx
, setX
, sety
, setY
, or teleport
in at least one place.pensize
pensize
or penSize
in at least one place.pencolor
pencolor
, color
, or penColor
in at least one place.fillcolor
fillcolor
, color
, or fillColor
in at least one place.begin_fill
begin_fill
or beginFill
in at least one place.end_fill
end_fill
or endFill
in at least one place.drawCircle
drawCircle
or circle
in at least one place.drawRectangle
drawRectangle
in at least one place.drawText
drawText
or write
in at least one place.penup
penup
, pu
, penUp
, teleport
, leap
, or hop
in at least one place.pendown
pendown
, pd
, penDown
, teleport
, leap
, or hop
in at least one place.title
title
in at least one place.