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 05:10
Read the code below. what will the computer print if the input for year_variable is 1700? if year_variable == 1776: print("your answer is correct. the declaration of independence was signed in “year_variable”.") elif year_variable < 1776: compute_variable = 1776 - year_variable. print("add “compute_variable“ years to your answer for the correct answer.") elif year_variable > 1776: compute_variable = year_variable - 1776 print("subtract “compute_variable” years from your answer for the correct answer.")
Answers: 1
question
Computers and Technology, 22.06.2019 12:40
In a response of approximately 50 words, explain why it would be essential for the successful a/v technician to participate in additional coursework, presentations and seminars offered by equipment manufacturers as well as annual conferences attended by colleagues in the industry.
Answers: 1
question
Computers and Technology, 23.06.2019 06:20
What is a point-in-time measurement of system performance?
Answers: 3
question
Computers and Technology, 23.06.2019 13:30
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
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, 12.08.2021 14:00
question
English, 12.08.2021 14:00
question
Computers and Technology, 12.08.2021 14:00
question
Mathematics, 12.08.2021 14:00
question
English, 12.08.2021 14:00
question
World Languages, 12.08.2021 14:00
Questions on the website: 13722367