# Makes (constructs) a SimpleTurtle object. # ---------------------------------------------------------------------- dave = rg.SimpleTurtle() # ---------------------------------------------------------------------- # Ask the SimpleTurtle objects to do things: # ---------------------------------------------------------------------- dave.forward(100) dave.left(90) dave.forward(200) # ---------------------------------------------------------------------- # Construct a new turtle and ask it to do things. # ---------------------------------------------------------------------- matt = rg.SimpleTurtle('turtle') matt.pen = rg.Pen('red', 30) matt.speed = 10 # Faster matt.backward(50) matt.left(90) matt.forward(50) matt.left(90) matt.pen = rg.Pen('yellow', 10) matt.forward(50) ######################################################################## # # DONE: 3. # Add a few more line of your own code above to make one of the # existing Turtles move some more and/or have different # characteristics. #
# ----------------------------------------------------------------------------- boris = rg.SimpleTurtle() # ----------------------------------------------------------------------------- # Ask the SimpleTurtle object to do things by applying METHODs to it: # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 10 # Faster natasha.backward(50) natasha.right(90) natasha.forward(50) natasha.speed = 40 natasha.left(90) natasha.forward(20) ############################################################################### # # DONE: 4. # Add a few more line of your own code to make one of the # existing SimpleTurtles move some more and/or have different # characteristics. #
that is 'brown' with thickness 5. Then makes the SimpleTurtle move as follows (in the order listed): -- forward 150 units -- left 90 degrees -- forward 50 units -- backward 100 units """ ########################################################################### # DONE: 4. Implement and test this function, per its doc-string above. # The testing code (in main) is already written for you. ########################################################################### window = rg.TurtleWindow() turtle = rg.SimpleTurtle() turtle.pen = rg.Pen('brown', 5) turtle.forward(150) turtle.left(90) turtle.forward(50) turtle.backward(100) ############################################################################### # IMPORTANT: Read the NOTE below before you try to implement the next function! ############################################################################### def try_functions(): """ Causes several SimpleTurtles to do the following: -- One jumps to (200, 100), then moves (while drawing) to (300, 30) -- One jumps to (100, 200), then moves (while drawing) to (0, 0) -- One jumps to (-50, 50), then moves (while drawing) to (100, 100)
# ----------------------------------------------------------------------------- # The next few lines show how to: # - Ask the SimpleTurtle object to do things by applying METHODs to it. # The numbers in the parentheses are called ARGUMENTS. # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # The next few lines show how to: # - Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 5 # Bigger means faster, max is usually about 10 natasha.backward(50) natasha.right(90) natasha.forward(125) natasha.speed = 1 # Now slower natasha.go_to(rg.Point(-100, 200)) ############################################################################### # # DONE: 4. # Add a few more lines of your own code to make one of the existing # SimpleTurtles move some more and/or have different characteristics. #
# 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() turtle1 = rg.SimpleTurtle('turtle') turtle1.speed = 7 turtle1.pen = rg.Pen('DarkSalmon', 4) turtle2 = rg.SimpleTurtle('turtle') turtle2.speed = 12 turtle2.pen = rg.Pen('lawn green',2) size = 400 for k in range(15): turtle1.draw_regular_polygon(4+k,size/3) turtle2.draw_regular_polygon(18-k,size/9) turtle1.pen_up() turtle1.right(45) turtle1.forward(20+k)
# You should have RUN the PREVIOUS module and READ its code. # (Do so now if you have not already done so.) # # Below this comment, add ANY CODE THAT YOUR WANT, as long as: # 1. You construct at least 2 rg.SimpleTurtle objects. # 2. Each rg.SimpleTurtle object draws something # (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg Window = rg.TurtleWindow() turtle = rg.SimpleTurtle('turtle') turtle.pen = rg.Pen('green', 2) turtle.speed = 10 size = 200 for k in range(13): turtle.draw_square(size) turtle.pen_up() turtle.right(45) turtle.forward(10) turtle.left(45) turtle.pen_down() size = size - 10 window.close_on_mouse_click()
# 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() blue_turtle = rg.SimpleTurtle('turtle') blue_turtle.pen = rg.Pen('midnight blue', 3) blue_turtle.speed = 20 red_turtle = rg.SimpleTurtle('turtle') red_turtle.pen = rg.Pen('red', 6) red_turtle.speed = 20 size = 300 for k in range(15): blue_turtle.draw_regular_polygon(5, size) blue_turtle.pen_up() blue_turtle.right(45 + 2 * k) blue_turtle.forward(10) blue_turtle.left(45 + 5 * k) blue_turtle.pen_down() size = size - 10
# (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT-and-PUSH when you are done with this module. ############################################################################### import rosegraphics as rg window = rg.TurtleWindow() red_turtle = rg.SimpleTurtle('turtle') red_turtle.pen = rg.Pen('pink', 15) red_turtle.speed = 15 size = 100 for k in range(10): red_turtle.draw_regular_polygon(5, 75) red_turtle.pen_up() red_turtle.left(16) red_turtle.forward(25) red_turtle.left(45) red_turtle.left(19) red_turtle.backward(60) red_turtle.pen_down()
def try_methods_and_functions(): """ Constructs a SimpleTurtle and sets its pen to a new rg.Pen that is 'blue' with thickness 5. Then makes the SimpleTurtle do the following (in the order listed): 1. Go backward 150 units. 2. Change its speed to 1 (slowest). Draw 2 squares whose size (width and height) are 100, each "twisted" from the previous by 30 degrees. 3. Change its speed to 5 (faster). Change its Pen's color to 'red'. Draw 10 squares whose size (width and height) are 50, each "twisted" from the previous by 15 degrees. 4. Change its speed to 100 (about the fastest possible). Change its Pen's thickness to 35. Draw 8 squares whose size (width and height) are 300, each "twisted" from the previous by 60 degrees. 5. Change its Pen to be a NEW Pen whose color is 'black' and whose thickness is 3. 6. Go backward 200 units. 7. Draw a CIRCLE whose radius is 30. 8. Draw a SQUARE whose sides are each of length 50. """ ########################################################################### # TODO: 6. Implement and test this function, per its doc-string above. # The testing code (in main) is already written for you. # # NOTE: This function should ** CALL ** the # draw_many_squares # function defined above. If you don't see why, ** ASK FOR HELP. ** ########################################################################### joey = rg.SimpleTurtle() joey.pen = rg.Pen('blue', 5) joey.backward(100) joey.speed = 1 draw_many_squares(joey, 2, 100, 30) joey.speed = 5 joey.pen = rg.Pen('red', 5) draw_many_squares(joey, 10, 50, 15) joey.speed = 100 joey.pen = rg.Pen('red', 35) draw_many_squares(joey, 8, 300, 60) joey.pen = rg.Pen('black', 3) joey.backward(200) joey.draw_circle(30) joey.draw_square(50)
# ----------------------------------------------------------------------------- # Ask the SimpleTurtle object to do things by applying METHODs to it: # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) boris.right(90) boris.forward(100) # ----------------------------------------------------------------------------- # Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 10 # Faster natasha.backward(50) natasha.right(90) natasha.forward(50) # ----------------------------------------------------------------------------- # My own code # ------------------------------------------------------------------------------ shuri = rg.SimpleTurtle('turtle') shuri.pen = rg.Pen('blue', 40) shuri.speed = 20 shuri.right(90) shuri.backward(50) shuri.forward(50)
# ---------------------------------------------------------------------- # Ask the SimpleTurtle objects to do things: # ---------------------------------------------------------------------- dave.forward(100) dave.left(45) dave.forward(200) dave.right(45) dave.backward(400) # ---------------------------------------------------------------------- # Construct a new turtle and ask it to do things. # ---------------------------------------------------------------------- matt = rg.SimpleTurtle('turtle') matt.pen = rg.Pen('red', 30) matt.speed = 10 # Faster matt.backward(50) matt.left(90) matt.forward(50) matt.right (45) matt.backward(400) ######################################################################## # # DONE: 3. # Add a few more line of your own code above to make one of the # existing Turtles move some more and/or have different # characteristics. #
# ----------------------------------------------------------------------------- boris = rg.SimpleTurtle() # ----------------------------------------------------------------------------- # Ask the SimpleTurtle object to do things by applying METHODs to it: # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 10 # Faster natasha.backward(50) natasha.right(90) natasha.forward(50) natasha.right(45) natasha.forward(75) natasha.right(45) natasha.forward(200) ############################################################################### # # Done: 4. # Add a few more line of your own code to make one of the # existing SimpleTurtles move some more and/or have different # characteristics.
def turtle4(): mo = rg.SimpleTurtle() mo.pen = rg.Pen("plum", 12) mo.forward(200) mo.right(50)
# (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() t95 = rg.SimpleTurtle('turtle') t95.pen = rg.Pen('orange',5) t95.speed = 10 for a in range(10): t95.draw_circle(radius=10+10*a) t95.pen_up() t95.right(90) t95.forward(10) t95.left(90) t95.pen_down() t110e3 = rg.SimpleTurtle('turtle') t110e3.pen = rg.Pen('red',3)
# Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow Bob = rg.SimpleTurtle('turtle') Jack = rg.SimpleTurtle('turtle') Bob.pen = rg.Pen('purple', 2) Jack.pen = rg.Pen('red', 2) Bob.speed = 10 Jack.speed = 10 size1 = 50 size2 = 100 for k in range(10): Bob.draw_circle(size1) Jack.draw_circle(size1) Bob.pen_up() Bob.right(45) Bob.forward(10) Bob.left(45)
# 2. Each rg.SimpleTurtle object draws something # (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() turtle1 = rg.SimpleTurtle('turtle') turtle1.pen = rg.Pen('red', 10) turtle2 = rg.SimpleTurtle('turtle') turtle2.pen = rg.Pen('DeepSkyBlue', 10) turtle1.speed = 100 turtle2.speed = 100 #put turtles in starting position turtle1.pen_up() turtle2.pen_up() turtle1.forward(100) turtle2.right(180) turtle2.forward(100) #define size size = 100
# The next few lines show how to: # - Ask the SimpleTurtle object to do things by applying METHODs to it. # The numbers in the parentheses are called ARGUMENTS. # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # The next few lines show how to: # - Construct a second SimpleTurtle # (using an optional argument that sets the shape displayed - try it!), # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle("turtle") natasha.pen = rg.Pen("red", 30) # Second argument is the Pen's thickness natasha.speed = 5 # Bigger means faster, max is usually about 10 natasha.backward(50) natasha.right(90) natasha.forward(125) natasha.speed = 1 # Now slower natasha.go_to(rg.Point(-100, 200)) ############################################################################### # TODO: 4. # Add a few more lines of your own code to make one of the existing # SimpleTurtles move some more and/or have different characteristics. # _ # ** Nothing fancy is required. **
# 2. Each rg.SimpleTurtle object draws something # (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT-and-PUSH when you are done with this module. # ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() turtle_one = rg.SimpleTurtle('turtle') turtle_one.pen = rg.Pen('Red', 5) turtle_one.speed = 15 size = 120 for k in range(12): turtle_one.draw_circle(size) turtle_one.pen_up() turtle_one.right(30) turtle_one.pen_down() size = size - 5 turtle_two = rg.SimpleTurtle('turtle') turtle_two_pen = rg.Pen('Green', 10) turtle_two.forward(5) turtle_two.speed = 10 for k in range(8): turtle_two.draw_square(200) turtle_two.pen_up()
# ----------------------------------------------------------------------------- # The next few lines show how to: # - Ask the SimpleTurtle object to do things by applying METHODs to it. # The numbers in the parentheses are called ARGUMENTS. # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # The next few lines show how to: # - Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 5 # Bigger means faster, max is usually about 10 natasha.backward(50) natasha.right(90) natasha.forward(125) natasha.left(60) natasha.speed = 1 # Now slower natasha.go_to(rg.Point(-100, 200)) ############################################################################### # # DONE: 4. # Add a few more lines of your own code to make one of the existing # SimpleTurtles move some more and/or have different characteristics.
# The numbers in the parentheses are called ARGUMENTS. # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) boris.right(225) boris.forward(300) # ----------------------------------------------------------------------------- # The next few lines show how to: # - Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 5 # Bigger means faster, max is usually about 10 natasha.backward(50) natasha.right(90) natasha.forward(125) natasha.speed = 1 # Now slower natasha.go_to(rg.Point(-100, 200)) natasha.speed = 7 natasha.forward(100) natasha.right(45) ############################################################################### #
# ----------------------------------------------------------------------------- boris = rg.SimpleTurtle() # ----------------------------------------------------------------------------- # Ask the SimpleTurtle object to do things by applying METHODs to it: # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 10 # Faster natasha.backward(50) natasha.right(90) natasha.forward(50) natasha.right(45) natasha.forward(39) steve = rg.SimpleTurtle('turtle') steve.pen = rg.Pen('blue', 15) # Second argument is the Pen's thickness steve.speed = 5 # Faster steve.left(30) steve.forward(30) steve.left(30)
# ----------------------------------------------------------------------------- # The next few lines show how to: # - Ask the SimpleTurtle object to do things by applying METHODs to it. # The numbers in the parentheses are called ARGUMENTS. # ----------------------------------------------------------------------------- boris.forward(100) boris.left(90) boris.forward(200) # ----------------------------------------------------------------------------- # The next few lines show how to: # - Construct a second SimpleTurtle, # set its pen and speed INSTANCE VARIABLES, and ask it to do things. # ----------------------------------------------------------------------------- natasha = rg.SimpleTurtle('turtle') natasha.pen = rg.Pen('red', 30) # Second argument is the Pen's thickness natasha.speed = 10 # Faster natasha.backward(50) natasha.right(90) natasha.forward(50) natasha.speed = 1 # Now slower natasha.go_to(rg.Point(-100, 200)) ############################################################################### # # DONE: 4. # Add a few more lines of your own code to make one of the # existing SimpleTurtles move some more and/or have different # characteristics.
# Makes (constructs) a SimpleTurtle object. # ---------------------------------------------------------------------- dave = rg.SimpleTurtle() # ---------------------------------------------------------------------- # Ask the SimpleTurtle objects to do things: # ---------------------------------------------------------------------- dave.forward(100) dave.left(90) dave.forward(200) # ---------------------------------------------------------------------- # Construct a new turtle and ask it to do things. # ---------------------------------------------------------------------- matt = rg.SimpleTurtle('turtle') matt.pen = rg.Pen('red', 30) matt.speed = 10 # Faster matt.backward(50) matt.left(90) matt.forward(50) matt.pen = rg.Pen("green", 22) matt.right(55) ######################################################################## # # doneTODO: 3. # Add a few more line of your own code above to make one of the # existing Turtles move some more and/or have different # characteristics.
pausing after typing the DOT (period, full stop). The window that pops up give lots of clues for what you can do! rg. rg.SimpleTurtle(). rg.Pen(). rg.PaintBucket(). Authors: David Mutchler, Dave Fisher, Vibha Alangar, Amanda Stouder, and their colleagues. """ import rosegraphics as rg window = rg.TurtleWindow() blue_turtle = rg.SimpleTurtle('turtle') blue_turtle.pen = rg.Pen('midnight blue', 3) blue_turtle.speed = 20 # Fast # The first square will be 300 x 300 pixels: size = 300 # Do the indented code 13 times. Each time draws a square. for k in range(40): # Put the pen down, then draw a square of the given size: blue_turtle.draw_square(size) # Move a little below and to the right of where the previous # square started. Do this with the pen up (so nothing is drawn). blue_turtle.pen_up() blue_turtle.right(45)
def try_methods_and_functions(): # IMPORTANT: Read the NOTE below before you try to solve this TO-DO! """ Constructs a SimpleTurtle and sets its pen to a new rg.Pen that is 'blue' with thickness 5. Then makes the SimpleTurtle do the following (in the order listed): 1. Go backward 150 units. 2. Change its speed to 1 (slowest). Draw 2 squares whose size (width and height) are 100, each "twisted" from the previous by 30 degrees. 3. Change its speed to 5 (faster). Change its Pen's color to 'red'. Draw 10 squares whose size (width and height) are 50, each "twisted" from the previous by 15 degrees. 4. Change its speed to 100 (about the fastest possible). Change its Pen's thickness to 35. Draw 8 squares whose size (width and height) are 300, each "twisted" from the previous by 60 degrees. 5. Changes its Pen to be a NEW Pen whose color is 'black' and whose thickness is 3. 6. Goes backward 200 units. 7. Draw a CIRCLE whose radius is 30. 8. Draw a SQUARE whose sides are each of length 50. """ ########################################################################### # DONE: 5. Implement and test this function, per its doc-string above. # (To test it, put a statement in main that calls this function.) # # NOTE: This function should ** CALL ** the # draw_many_squares # function defined above. If you don't see why, ** ASK FOR HELP. ** # ########################################################################### jim = rg.SimpleTurtle() jim.backward(150) jim.speed = 2 draw_many_squares(jim, 2, 100, 30) jim.speed = 5 jim.pen = rg.Pen('red', 5) draw_many_squares(jim, 10, 50, 15) jim.speed = 100 jim.pen = rg.Pen('red', 35) draw_many_squares(jim, 8, 300, 60) jim.pen = rg.Pen('black', 3) jim.backward(300) jim.draw_circle(30) jim.draw_square(50)
# - Makes the SimpleTurtle go 150 pixels straight DOWN. # # Don't forget to: # - import rosegraphics and construct a TurtleWindow # at the BEGINNING of your code, and to # - ask your TurtleWindow to close_on_mouse_click # as the LAST line of your code. # See the beginning and end of m4e_loopy_turtles for an example. # # As always, test by running the module. # As always, COMMIT-and-PUSH when you are done with this module. # ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() turtle = rg.SimpleTurtle('turtle') turtle.pen = rg.Pen('blue', 20) turtle.speed = 1 turtle.left(90) turtle.forward(200) turtle.pen_up() turtle.go_to(rg.Point(100, -40)) turtle.pen_down() turtle.pen = rg.Pen('green', 10) turtle.backward(150) window.close_on_mouse_click()
# Don't forget to: # - import rosegraphics and construct a TurtleWindow # at the BEGINNING of your code, and to # - ask your TurtleWindow to close_on_mouse_click # as the LAST line of your code. # See the beginning and end of m4e_loopy_turtles for an example. # # As always, test by running the module. # As always, COMMIT-and-PUSH when you are done with this module. # ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() top_turtle = rg.SimpleTurtle('classic') top_turtle.pen = rg.Pen('red', 3) top_turtle.left(90) top_turtle.forward(200) top_turtle.pen_up() top_turtle.go_to(rg.Point(-100, 200)) top_turtle.pen_down() top_turtle.pen = rg.Pen('green', 10) top_turtle.right(180) top_turtle.forward(150) window.close_on_mouse_click()
# Makes (constructs) a SimpleTurtle object. # ---------------------------------------------------------------------- dave = rg.SimpleTurtle() # ---------------------------------------------------------------------- # Ask the SimpleTurtle objects to do things: # ---------------------------------------------------------------------- dave.forward(100) dave.left(90) dave.forward(200) # ---------------------------------------------------------------------- # Construct a new turtle and ask it to do things. # ---------------------------------------------------------------------- matt = rg.SimpleTurtle('turtle') matt.pen = rg.Pen('red', 30) matt.speed = 10 # Faster matt.backward(50) matt.left(90) matt.forward(50) dave.pen = rg.Pen('blue', 15) dave.right(45) dave.backward(200) ######################################################################## # # DONE: 3. # Add a few more line of your own code above to make one of the # existing Turtles move some more and/or have different # characteristics.
Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher, Amanda Stouder, Aaron Wilkin, and their colleagues. """ import rosegraphics as rg ############################################################################### # One window, for two examples. ############################################################################### window = rg.TurtleWindow() ############################################################################### # Example 1. ############################################################################### blue_turtle = rg.SimpleTurtle('turtle') blue_turtle.pen = rg.Pen('midnight blue', 3) blue_turtle.speed = 20 # Fast # The first square will be 300 x 300 pixels: size = 150 # Do the indented code 6 times. Each time draws a square. for k in range(6): # Put the pen down, then draw a square of the given size: blue_turtle.draw_square(size) # Move a little below and to the right of where the previous # square started. Do this with the pen up (so nothing is drawn). blue_turtle.pen_up() blue_turtle.right(45)
# (by moving, using its rg.Pen). ANYTHING is fine! # 3. Each rg.SimpleTurtle moves inside a LOOP. # # Be creative! Strive for way-cool pictures! Abstract pictures rule! # # If you make syntax (notational) errors, no worries -- get help # fixing them at either this session OR at the NEXT session. # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## import rosegraphics as rg window = rg.TurtleWindow() alexis = rg.SimpleTurtle('turtle') alexis.pen = rg.Pen('red', 5) alexis.speed = 30 size = 300 for k in range(13): alexis.draw_square(30) alexis.pen_up() alexis.left(12) alexis.forward(4) alexis.pen_down() size = size alexis.pen_up()