[CSC 125] Program 3
Andrew J. Pounds
pounds_aj at mercer.edu
Tue Jul 24 12:21:49 EDT 2012
On 07/24/2012 11:43 AM, wrote:
> Thanks.
> Another thing concerning the Programming Assignment. I ran the program
> and see the shapes drawn, but I'm not too certain about what to do
> next. The directions say "Now look at the code itself," but I think
> that is where I am getting stuck because I'm not sure what code I am
> looking at.
>
Here are the two functions that I wrote...
# This function draws a polygon
def polygon(length_of_side, number_of_sides):
for i in range (number_of_sides):
turtle.forward(length_of_side)
turtle.left(360/number_of_sides)
# This function positions the turtle
def position(x,y):
turtle.penup()
turtle.setposition(x,y)
turtle.pendown()
Later in the code you will see things like...
position(100,100)
polygon(100,5)
If you compare these back to the two functions you will see that the
first of these
sets the POSITION of the turtle in x and y coordinates. The second of
these draws
a POLYGON with the first argument defining the size of the polygon and
the second one
defining the number of sides.
turtle.circle(100)
is similar but only has one argument, the size of the circle.
Your job is to change the arguments to the position, polygon, and circle
functions
to meet the requirements of the exercise.
For example -- try this
position(125,-10)
polygon(50,5)
and see what happens to your pentagon.
--
Andrew J. Pounds, Ph.D. (pounds at theochem.mercer.edu)
Associate Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc125/attachments/20120724/d2b27013/attachment.html>
More information about the csc125
mailing list