ExamVeda
Login
Home
Generators and Iterators
?

What is a coroutine in Python?

Answer & Solution
Correct Answer: Option C
The correct answer is Option C: A function that can yield control and later resume.
A coroutine in Python is a function that can yield control back to the caller and later resume execution from the point it left off. Unlike regular functions, which execute to completion and return a single value, coroutines can yield values using the yield statement, allowing for cooperative multitasking and asynchronous programming. Coroutines are commonly used in asynchronous frameworks like asyncio to handle concurrent execution and manage asynchronous tasks efficiently.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.