Contenuti del Corso
Python Functions Tutorial
Python Functions Tutorial
1. What is a Function in Python?
2. Positional and Optional Arguments
4. Function Return Value Specification
Challenge: Automated Bus Announcements
Compito
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.
- Use an infinite loop to cycle through the stops continuously.
- Iterate over each stop in the
stops
list. - Use
yield
to return the current stop in the format"Next stop: {stop}"
.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 4. Capitolo 5
Challenge: Automated Bus Announcements
Compito
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.
- Use an infinite loop to cycle through the stops continuously.
- Iterate over each stop in the
stops
list. - Use
yield
to return the current stop in the format"Next stop: {stop}"
.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 4. Capitolo 5