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

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()
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
Similar Questions
    1. answers icon 3 answers
  1. Which of the following is an example of negative acceleration?a a runner speeds up at the end of a race b a car slowing down at
    1. answers icon 1 answer
  2. Jacinda draws a rectangle with measurements 6 cm and 3 cm.What is the area of the rectangle in square centimeters?
    1. answers icon 1 answer
  3. Use the image to answer the question.Jacinda draws a rectangle with measurement 6 cm and 3 cm. What is the area of the rectangle
    1. answers icon 1 answer
more similar questions