PythonFan.org
Toggle Menu
Home
Online Python Compiler
Tutorials
Python FastAPI
Python Pandas
Python PyTorch
Python Seaborn
Blog
All Posts
Building APIs With FastAPI
Check your understanding of routes,requests,and responses in FastAPI.
1. Who is the creator of FastAPI?
Guido van Rossum
Sebastian Ramirez
Raymond Hettinger
2. Which of the following are key features of FastAPI?
Automatic OpenAPI documentation
Async/await support
Static type hinting integration
No built-in data validation
3. FastAPI is built on top of the Starlette framework.
True
False
4. What Python library does FastAPI use for data validation and parsing (abbrev.)?
5. Which HTTP method decorator is used to handle resource creation in FastAPI?
@app.get
@app.post
@app.put
6. Which of the following are valid ways to define query parameters in FastAPI?
Function parameters with default values
Using the Query() function
Including them in the URL path
As Pydantic model fields
7. Path parameters in FastAPI are enclosed in square brackets [].
True
False
8. What is the default endpoint for FastAPI's interactive Swagger UI documentation?
9. Which class must a Pydantic model inherit from to define request bodies?
BaseModel
RequestBody
Schema
10. Which of the following are supported by FastAPI's dependency injection system?
Singleton dependencies
Async dependency functions
Class-based dependencies
Only synchronous dependencies
11. FastAPI endpoints can return Python dictionaries, which are automatically converted to JSON.
True
False
12. What is the term for a function that runs after returning a response, often used for cleanup tasks?
13. How do you make a query parameter required in FastAPI?
Omit a default value
Add a 'required' flag
Use the Required type
14. Which status codes can be returned using FastAPI's status module?
status.HTTP_201_CREATED
status.HTTP_404_NOT_FOUND
status.HTTP_500_INTERNAL_SERVER_ERROR
status.HTTP_300_MULTIPLE_CHOICES
15. FastAPI does not support synchronous endpoint functions.
True
False
16. What command is commonly used to run a FastAPI application during development (starts with 'uvicorn')?
17. Which middleware is used to handle Cross-Origin Resource Sharing (CORS) in FastAPI?
CORSHandler
CORSMiddleware
CrossOriginMiddleware
18. Which of the following are benefits of using Pydantic models in FastAPI?
Automatic data validation
Type conversion
Automatic API schema generation
Database ORM integration
19. FastAPI's dependency injection system caches dependencies by default (singleton scope).
True
False
20. What is the full form of 'OpenAPI', the standard used by FastAPI for API documentation?
Reset
Answered 0 of 0 — 0 correct