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

Kursinnehåll

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

Uppgift

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}".

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 5
toggle bottom row

book
Challenge: Automated Bus Announcements

Uppgift

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}".

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 5
Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Vi beklagar att något gick fel. Vad hände?
some-alt