You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

07_filled_square_methods.py 405B

3 months ago
123456789101112131415161718
  1. from turtle import Turtle
  2. def draw_square(turtle, length):
  3. for _ in range(4):
  4. turtle.forward(length)
  5. turtle.right(90)
  6. def draw_filled_square(turtle, length):
  7. turtle.begin_fill()
  8. draw_square(turtle, length)
  9. turtle.end_fill()
  10. Turtle.draw_filled_square = draw_filled_square
  11. sophia = Turtle()
  12. sophia.fillcolor('red')
  13. sophia.draw_filled_square(100)
  14. sophia.screen.mainloop()