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, 23.06.2019 02:30
Experimental data that is expressed using numbers is said to be
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Write and test a python program to find and print the largest number in a set of real (floating point) numbers. the program should first read a single positive integer number from the user, which will be how many numbers to read and search through. after reading in all of the numbers, the largest of the numbers input (not considering the count input) should be printed.
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, 05.11.2020 02:30
question
English, 05.11.2020 02:30
Questions on the website: 13722362