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

Kursinnhold

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

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 5
toggle bottom row

book
Challenge: Automated Bus Announcements

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 5
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt