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

Kursusindhold

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

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 5
toggle bottom row

book
Challenge: Automated Bus Announcements

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 5
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt