Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Traffic lights | Function Return Value Specification
Python Functions Tutorial
course content

Contenido del Curso

Python Functions Tutorial

Python Functions Tutorial

1. What is Function in Python?
2. Positional and Optional Arguments
3. Arbitrary Arguments
4. Function Return Value Specification
5. Recursion and Lambda Functions

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 5
toggle bottom row

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 5
toggle bottom row

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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:

  1. Write a generator traffic_light_generator that yields the state of the traffic light ("Red", "Yellow", "Green") in an infinite loop.
  2. 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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 5
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt