How is a coroutine defined in Python using the async keyword?
A. coroutine def
B. def coroutine
C. async def
D. def async
Answer: Option C
Solution (By Examveda Team)
The correct answer is Option C: async def.In Python, a coroutine is defined using the async def syntax. This keyword combination indicates to the interpreter that the function is a coroutine, allowing it to use asynchronous features such as await expressions and yield statements within the function body. The async def syntax is specifically designed for defining coroutines, providing a clear and concise way to declare asynchronous functions in Python.
What is a generator in Python?
A. A function that generates random numbers
B. A special type of list
C. A way to define classes
D. A function that yields values one at a time
How is a generator different from a regular function?
A. A generator uses the return keyword
B. A generator can yield multiple values
C. A generator uses the break statement
D. A generator uses the continue statement
What is an advantage of using generators for large datasets?
A. They use more memory
B. They are slower than loops
C. They are easier to implement
D. They use less memory
How do you define a generator function in Python?
A. Using the generator keyword
B. Using the def keyword and yield statement
C. Using the gen keyword
D. Using the function keyword

Join The Discussion