|
123456789101112131415161718 |
- from turtle import Turtle
-
- def draw_square(turtle, length):
- for _ in range(4):
- turtle.forward(length)
- turtle.right(90)
-
- def draw_filled_square(turtle, length):
- turtle.begin_fill()
- draw_square(turtle, length)
- turtle.end_fill()
-
- Turtle.draw_filled_square = draw_filled_square
- sophia = Turtle()
- sophia.fillcolor('red')
- sophia.draw_filled_square(100)
-
- sophia.screen.mainloop()
|