57 lines
1.1 KiB
Python
57 lines
1.1 KiB
Python
import turtle as tt
|
|
|
|
def turtle_04():
|
|
"""Draw three squares in a row with a gap between each. Fill them using
|
|
three different colours."""
|
|
# Settings
|
|
tt.bgcolor("black")
|
|
tt.color("magenta")
|
|
tt.pensize(3)
|
|
tt.speed(1)
|
|
|
|
def sqr_draw1(color):
|
|
tt.down()
|
|
tt.fillcolor(color)
|
|
tt.begin_fill()
|
|
tt.back(100)
|
|
tt.left(90)
|
|
tt.forward(100)
|
|
tt.right(90)
|
|
tt.down()
|
|
tt.forward(100)
|
|
tt.right(90)
|
|
tt.forward(100)
|
|
tt.end_fill()
|
|
|
|
def sqr_draw2_3(color):
|
|
tt.down()
|
|
tt.fillcolor(color)
|
|
tt.begin_fill()
|
|
tt.forward(100)
|
|
tt.left(90)
|
|
tt.forward(100)
|
|
tt.left(90)
|
|
tt.forward(100)
|
|
tt.left(90)
|
|
tt.forward(100)
|
|
tt.end_fill()
|
|
|
|
# Square 1
|
|
tt.up()
|
|
tt.back(75)
|
|
sqr_draw1('yellow')
|
|
|
|
# Square 2
|
|
tt.up()
|
|
tt.left(90)
|
|
tt.forward(25)
|
|
sqr_draw2_3('orange')
|
|
|
|
# Square 3
|
|
tt.up()
|
|
tt.left(90)
|
|
tt.forward(125)
|
|
sqr_draw2_3('green')
|
|
|
|
tt.exitonclick()
|