Interview Question

What is async/await?

async creates coroutines; await pauses them for awaitable results.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

async def defines a coroutine function, and await suspends a coroutine until an awaitable completes. • Calling a coroutine function creates a coroutine object. • A coroutine must be awaited or scheduled. • await is valid inside async functions and related asynchronous constructs.

💡 Simple Example

import asyncio async def answer(): await asyncio.sleep(0) return 42 print(asyncio.run(answer()))

Output

42

⚡ Quick Revision

async creates coroutines; await pauses them for awaitable results.