import turtle
# Set up the screen
wn = turtle.Screen()
wn.bgcolor("lightgray")
wn.title("Stoplight")
# Draw the rectangle
turtle.penup()
turtle.goto(-50, -50)
turtle.pendown()
turtle.fillcolor("gray")
turtle.begin_fill()
for i in range(2):
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.end_fill()
# Draw the circles
BUFFER = 20
turtle.penup()
turtle.goto(-25, 0)
turtle.fillcolor("red")
turtle.pendown()
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(0, 0)
turtle.fillcolor("yellow")
turtle.pendown()
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
turtle.penup()
turtle.goto(25 + BUFFER, 0)
turtle.fillcolor("green")
turtle.pendown()
turtle.begin_fill()
turtle.circle(25)
turtle.end_fill()
# Hide the turtle
turtle.hideturtle()
# Exit on click
wn.exitonclick()
Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in the rectangle. The circles should be red, then yellow, then green. You should use the drawCircle function from the video.
The rectangle should be centered on the screen. The yellow light should be centered on the screen, and the red and green light should be offset by BUFFER amount.
2 answers
i am losing my mind here. does this actually work?
even if it doesn't work, it's a good start anyway. i can't believe it
even if it doesn't work, it's a good start anyway. i can't believe it