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

Course Content

Python Functions Tutorial

Python Functions Tutorial

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

book
Challenge: Automated Bus Announcements

Task

Swipe to start coding

If you've ever ridden a bus or tram, you know that station announcements are pre-recorded and cycle continuously. Implement a generator function bus_announcements to simulate an automated bus announcement system.

  1. Use an infinite loop to cycle through the stops continuously.
  2. Iterate over each stop in the stops list.
  3. Use yield to return the current stop in the format "Next stop: {stop}".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 5
toggle bottom row

book
Challenge: Automated Bus Announcements

Task

Swipe to start coding

If you've ever ridden a bus or tram, you know that station announcements are pre-recorded and cycle continuously. Implement a generator function bus_announcements to simulate an automated bus announcement system.

  1. Use an infinite loop to cycle through the stops continuously.
  2. Iterate over each stop in the stops list.
  3. Use yield to return the current stop in the format "Next stop: {stop}".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 5
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt