Async: waiting without blocking
async def defines a coroutine. await pauses it until an awaitable completes, letting other tasks run. This is useful for I/O waiting, not a magic speedup for CPU-heavy work. asyncio.gather schedules multiple coroutines.
हिन्दी में समझें
async def कोरूटीन बनाता है। await इंतजार में उसे रोककर दूसरे टास्क को मौका देता है। यह I/O के इंतजार में उपयोगी है, भारी गणना को जादू से तेज नहीं करता।
अभ्यास: greet("Dev") को await करें और अभिवादन प्रिंट करें।
Hinglish mein samjhein
async def coroutine banata hai. await wait karte waqt doosre tasks ko run karne deta hai. I/O waiting ke liye useful hai, CPU-heavy work ki magic speedup nahi.
Practice: greet("Dev") await karke greeting print karo.
A small Python example
import asyncio
async def greet(name):
await asyncio.sleep(0.01)
return f"Hello {name}"
print(await greet("Asha"))The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.
Try this example in the Python playground →Practise this idea
Await greet("Dev") and print the greeting.
Check answer & explanation
import asyncio
async def greet(name):
await asyncio.sleep(0.01)
return f"Hello {name}"
print(await greet("Dev"))await waits for the coroutine to finish and returns its greeting. This browser accepts top-level await; a normal script needs an async entry point.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
Async is especially useful for…
Check the quiz answer
Waiting on I/O
Async lets other tasks progress during I/O waiting.
References & corrections
Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.