import turtle screen = turtle.Screen() turtle = turtle.Turtle() turtle.goto(0, 0) # this draws the polygon that will be repeated # if you call polyroll with 90 as the first angle # for example it will create a spiral of squares def polystop(side, angle): turn = 0 turtle.forward(side) turtle.right(angle) turn = turn + angle while turn%360 != 0: turtle.forward(side) turtle.right(angle) turn = turn + angle def polyroll(side, angle1, angle2): for x in range(20): polystop(side, angle1) turtle.right(angle2) # uncomment the following lines to see some examples # polyroll(100, 90, 30) # polyroll(10, 10, 110) # polyroll(50, 40, 95) # polyroll(50, 30, 95) polyroll(50, 45, 121)
  • Run Code
  • Show Console
  • Codesters How To (opens in a new tab)