Editor

Define a Coroutine

Advanced · Write the code · from Python Async/Await: Write Non-Blocking Code from Scratch

From the lesson: Python Async/Await: Write Non-Blocking Code from Scratch

Imagine you're a chef in a busy kitchen. You don't stand and watch the oven for 20 minutes while your pasta boils on another burner. Instead, you start the oven, move to the pasta, then check the salad -- all without waiting idle. That's exactly what asynchronous programming does for your code.

Read the lesson

Write an async def function called greet that takes a name parameter and returns the string Hello, <name>! Welcome to async Python. (where <name> is replaced with the argument). Then, outside the function, print the type of the object returned by calling greet('World') (do NOT await it).

# Define an async function called greet

More Async and Await exercises

All Python exercises · 50 practice problems · Advanced Python quiz