Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!