Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: from this code, the user must be able to select the color of the traffic light. import time from time import sleep from tkinter

PYTHON: from this code, the user must be able to select the color of the traffic light.

import time from time import sleep from tkinter import * tk=Tk() win=Canvas(tk, width=55, height=200) win.pack() #functions def red(a): for i in range(a): red=win.create_oval(5,5,50,50, fill="red") tk.update() time.sleep(0.05) def redb(a): for i in range(a): red=win.create_oval(5,5,50,50, fill="black") tk.update() time.sleep(0.05) def amber(a): for i in range(a): amber=win.create_oval(5,55,50,100, fill="orange") tk.update() time.sleep(0.05) def amberb(a): for i in range(a): amber=win.create_oval(5,55,50,100, fill="black") tk.update() time.sleep(0.05) def green(a): for i in range(a): green=win.create_oval(5,105,50,150, fill="green") tk.update() time.sleep(0.05) def greenb(a): for i in range(a): green=win.create_oval(5,105,50,150, fill="black") tk.update() time.sleep(0.05) def lights(): red=win.create_oval(5,5,50,50, fill="black") amber=win.create_oval(5,55,50,100, fill ="black") green=win.create_oval(5,105,50,150, fill="black") #end of functions #calling the functions

lights() red(30) redb(1) amber(10) amberb(1) green(30) greenb(1)

tk.mainloop()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions