def main(): # create world and turtle earth = makeWorld(800, 800) fred = makeTurtle ( earth ) bob = makeTurtle ( earth ) # change default turtle color to blue # using setPenColor METHOD fred.setPenColor ( blue ) bob.setPenColor ( green ) drawCircle ( fred, 10 ) drawStar ( fred, 250, red ) fred.setPenColor ( green ) drawArc ( fred, 10 ) drawStar ( fred, 250, red ) def drawArc ( t1, length ): # draw Circle: turn for the angle: 360 / number of sides # draw a many sided polygon ==> 30 # turn = 360 / 30 = 12 xPos = getXPos ( t1 ) yPos = getYPos ( t1 ) loopCount = 1 while ( loopCount <= 15 ) : # draw the line and turn for each side of the shape forward ( t1, length ) turn ( t1, 360 / 30 ) # increment my loopCount variable loopCount = loopCount + 1 # move the turtle back to its starting position penUp( t1 ) moveTo (t1, xPos, yPos) turn ( t1, 180 ) penDown( t1 ) def drawStar ( t1, length, c ): # draw a 5 pointed star, total turns is 720 degrees # Each of tghe the 5 turns should be 720 / 4 ==> 144 # save the turtle current pen color so the state of the # turtle can be 100% restored originalColor = t1.getPenColor( ) t1.setPenColor ( c ) # draw my shape count = 1 while ( count <= 5 ): forward ( t1, length ) turn ( t1, 144 ) count = count + 1 # restore the turtle's original pen color t1.setPenColor ( originalColor ) def repositionTurtle ( t1, deltaX, deltaY ): # In keeping the the coordinate axis system of pictures in JES # x direction is horizontal ( positive direction to the right ) # y direction is vertical ( positive direction is down ) # reposition turtle right deltaX pixels and down deltaY pixels penUp ( t1 ) turn ( t1, 90 ) # point in the positive x direction forward ( t1, deltaX ) turn ( t1, 90 ) # point in the positive y direction forward ( t1 , deltaY ) turn ( t1, 180 ) penDown ( t1 ) def takeCourse ( prof, subject, number, student ): print ( "Hello" ) def drawCircle ( t1, length ): # draw Circle: turn for the angle: 360 / number of sides # draw a many sided polygon ==> 30 # turn = 360 / 30 = 12 loopCount = 1 while ( loopCount <= 30 ) : # draw the line and turn for each side of the shape forward ( t1, length ) turn ( t1, 360 / 30 ) # increment my loopCount variable loopCount = loopCount + 1 def drawOct ( t1, length ): # draw octagon: turn for the angle: 360 / number of sides # turn = 360 / 8 = 45 loopCount = 1 while ( loopCount <= 8 ) : # draw the line and turn for each side of the shape forward ( t1, length ) turn ( t1, 45 ) # increment my loopCount variable loopCount = loopCount + 1 def drawHex ( t1, length ): # draw hexagon: turn for the angle: 360 / number of side # turn = 360 / 6 = 60 loopCount = 1 while ( loopCount <= 6 ) : # draw the line and turn for each side of the shape forward ( t1, length ) turn ( t1, 60 ) # increment my loopCount variable loopCount = loopCount + 1