Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following class and main function, fill in the output from each statement on the given line: class TrafficLight: def _ init _ (

Given the following class and main function, fill in the output from each statement on the given line: class TrafficLight: def _init_(self, initial_color = "green", cars_waiting =0): self. color = initial_color self. cars_waiting = cars_waiting First Ave: green -> yellow, 0 def cycle_color (self) : Second Ave: red -> green, 4 if self. color == "green": self. color = "yellow" elif self. color == "yellow": self. color = "red" elif self. color == "red" and self. cars_waiting >=10: self. color = "green" def _str_(self): return "Color: "+ self. color +" Cars: "+ str(self.cars_waiting) def main () : first_ave = TrafficLight() second_ave = TrafficLight("red",4) first_ave. cycle_color () second_ave . cycle_color () print( "Second Avenue: ", second_ave) Error second_ave . cars_waiting +=6 second_ave . cycle_color () print( "First Avenue:", first_ave) Error print( "Second Avenue: ", second_ave) Error main()

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions