Async & APIs with FastAPI — Practice quiz
Untimed. Answers are graded when you submit, with explanations and spaced-repetition scheduling.
- Question 1easy
What does an `async def` function return when called?
- Question 2easy
Which asyncio call is the equivalent of JavaScript's `Promise.all([...])`?
- Question 3medium
What happens if you call an async function but forget to await it?
- Question 4medium
For which kind of work does async/await actually help?
- Question 5medium
Why use httpx's AsyncClient instead of the requests library inside async code?
- Question 6easy
In FastAPI, what does `@app.get('/health')` do?
- Question 7medium
In `async def get_topic(topic_id: str, verbose: bool = False)` on route `/topics/{topic_id}`, where does `verbose` come from?
- Question 8medium
What role does a pydantic BaseModel play in a FastAPI endpoint?
- Question 9medium
A client POSTs `{ "top_k": "four" }` to an endpoint expecting `top_k: int`. What does FastAPI do?
- Question 10hard
What is the main benefit of injecting a resource via `Depends(get_settings)` instead of importing it directly?
- Question 11hard
Which statements about `asyncio.run(main())` are true? (Select all that apply)
Select all that apply.
- Question 12medium
What does `async with httpx.AsyncClient() as client:` provide?
- Question 13medium
Name the ASGI server command commonly used to run a FastAPI app in development (the program name is enough).
- Question 14hard
One word: async gives you ______ (overlapping I/O waits), not true parallelism of CPU work.