Contenido del Curso
Python Functions Tutorial
Python Functions Tutorial
Challenge: Traffic lights
Tarea
Task Description:
Write a Python program that simulates a traffic light using a generator. The program should display the state of the traffic light ("Red"
, "Yellow"
, "Green"
) for a specified number of cycles.
Task Conditions:
- Write a generator
traffic_light_generator
that yields the state of the traffic light ("Red"
,"Yellow"
,"Green"
) in an infinite loop. - Use this generator to output the state of the traffic light to the console nine times in the program.
Example Output:
Note that the program should use the generator to create the sequence of traffic light states, and the output should occur within the specified number of cycles.
¡Gracias por tus comentarios!
Challenge: Traffic lights
Tarea
Task Description:
Write a Python program that simulates a traffic light using a generator. The program should display the state of the traffic light ("Red"
, "Yellow"
, "Green"
) for a specified number of cycles.
Task Conditions:
- Write a generator
traffic_light_generator
that yields the state of the traffic light ("Red"
,"Yellow"
,"Green"
) in an infinite loop. - Use this generator to output the state of the traffic light to the console nine times in the program.
Example Output:
Note that the program should use the generator to create the sequence of traffic light states, and the output should occur within the specified number of cycles.
¡Gracias por tus comentarios!
Challenge: Traffic lights
Tarea
Task Description:
Write a Python program that simulates a traffic light using a generator. The program should display the state of the traffic light ("Red"
, "Yellow"
, "Green"
) for a specified number of cycles.
Task Conditions:
- Write a generator
traffic_light_generator
that yields the state of the traffic light ("Red"
,"Yellow"
,"Green"
) in an infinite loop. - Use this generator to output the state of the traffic light to the console nine times in the program.
Example Output:
Note that the program should use the generator to create the sequence of traffic light states, and the output should occur within the specified number of cycles.
¡Gracias por tus comentarios!
Tarea
Task Description:
Write a Python program that simulates a traffic light using a generator. The program should display the state of the traffic light ("Red"
, "Yellow"
, "Green"
) for a specified number of cycles.
Task Conditions:
- Write a generator
traffic_light_generator
that yields the state of the traffic light ("Red"
,"Yellow"
,"Green"
) in an infinite loop. - Use this generator to output the state of the traffic light to the console nine times in the program.
Example Output:
Note that the program should use the generator to create the sequence of traffic light states, and the output should occur within the specified number of cycles.