subject

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. 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. BUFFER amount represents the distance from the center of one circle to the center of another circle.

Implement the function draw_circle that draws a single circle. Use it to draw the red, yellow, and green lights. Since all of the lights are the same size and aligned vertically, the function only needs to take the y position and color as arguments.

Note: Be sure to include comments for all functions that you use or create.

THIS IS WHAT I HAVE and I have error codes: any help??

# This program should draw a stop light

LIGHT_RADIUS = 25
STOPLIGHT_WIDTH = 100
STOPLIGHT_HEIGHT = 250
BUFFER = 75

# Implement a function that draws a single circle
# with radius LIGHT_RADIUS.
# The circle should be in the center of the screen horizontally.
# Use the parameters for the y position and color
def draw_circle(y_pos, color):
circ = Circle(LIGHT_RADIUS)
circ. set_postition(get_width()/2, y-pos)
circ. set_color(color)
add(circ)
draw_circle(get_height()/2 - BUFFER, Color. red)
draw_circle(get_height()/2, Color. yellow)
draw_circle(get_height()/2 + BUFFER, Color. green)

def draw_rectangle():
rect= Rectangle(STOPLIGHT_WIDTH, STOPLIGHT_HEIGHT)
rect. set_postion(get_width()/2 - STOPLIGHT_WIDTH/2, get_height()/2 - STOPLIGHT_HEIGHT/2)
rect. set_color(Color. grey)
add(rect)
draw_rectangle()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:30
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
question
Computers and Technology, 22.06.2019 14:40
You begin your first day of responsibilities by examining the recent is security breach at gearup to get ideas for safeguards you will take. at gearup, criminals accessed the company's improperly-secured wireless system and stole customers' credit card information as well as employee social security numbers. what kind of computer crime did gearup face?
Answers: 3
question
Computers and Technology, 22.06.2019 21:30
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
You know the right answer?
Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in...
Questions
question
Mathematics, 05.05.2020 00:33
question
Mathematics, 05.05.2020 00:33
question
Mathematics, 05.05.2020 00:33
Questions on the website: 13722361