Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What is a coroutine?
Think of it as a generator that can do more than just yield.
What keyword is used to pause execution in a coroutine?
It's also used to send back a value to the caller.
What keyword is used to return a value in a coroutine and pause its execution?
Think of how generators behave.
Can a coroutine send values back to the caller?
Consider the names of the methods we discussed.
Create a coroutine that tracks the average of numbers sent to it. Include features to print the running average each time a new number is added.
Calculate the average carefully—consider how you can keep track of both sum and count!
Discuss how you might implement a coroutine for real-time data processing in an application like a live chat. What features would it need?
Think about challenges associated with managing incoming messages and state transitions.
6 more questions in this section. Enroll free to practise them all.
Enroll free