Fast API MCQs with answers Page - 11

Here, you will find a collection of MCQ questions on Fast API. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

R

Ravina • 3.59K Points
Extraordinary

Q. How can you make a FastAPI route accessible at `/api/items`?

  • (A) Use @app.route('/api/items')
  • (B) Use @app.endpoint('/api/items')
  • (C) Use @app.get('/api/items')
  • (D) Use @app.path('/api/items')

R

Ravina • 3.59K Points
Extraordinary

Q. Which keyword is used for declaring asynchronous endpoints?

  • (A) sync
  • (B) async
  • (C) await
  • (D) def

R

Ravina • 3.59K Points
Extraordinary

Q. What is the purpose of `response_model_exclude_unset=True`?

  • (A) Returns all fields, including unset ones
  • (B) Hides default values
  • (C) Only returns fields that were set by the user
  • (D) Raises error on unset fields

R

Ravina • 3.59K Points
Extraordinary

Q. Which tool can auto-generate a client SDK from a FastAPI server?

  • (A) Swagger Codegen
  • (B) OpenAPI Codegen
  • (C) ReDoc Generator
  • (D) Postman Studio

R

Ravina • 3.59K Points
Extraordinary

Q. Which parameter in `Path()` ensures a parameter must be greater than zero?

  • (A) gt=0
  • (B) min=1
  • (C) greater=0
  • (D) positive=True

R

Ravina • 3.59K Points
Extraordinary

Q. What would `Field(default=None, title='Age')` do in a Pydantic model?

  • (A) Make field required
  • (B) Assign a default of 0
  • (C) Add title metadata and default value
  • (D) Hide the field

R

Ravina • 3.59K Points
Extraordinary

Q. How can you automatically reload a FastAPI app during development?

  • (A) Use `--watch`
  • (B) Use `--reload` with Uvicorn
  • (C) Enable autoreload in config
  • (D) Use FastAPI dev mode

R

Ravina • 3.59K Points
Extraordinary

Q. What happens if type hints are missing in FastAPI route parameters?

  • (A) They are ignored
  • (B) They are treated as strings
  • (C) FastAPI raises an error
  • (D) They are auto-converted

R

Ravina • 3.59K Points
Extraordinary

Q. What is the recommended way to structure large FastAPI projects?

  • (A) Single main.py file
  • (B) Blueprint pattern
  • (C) Modular structure using APIRouter
  • (D) Use Django apps

R

Ravina • 3.59K Points
Extraordinary

Q. What is `status.HTTP_201_CREATED` in FastAPI?

  • (A) A constant for 201 status code
  • (B) A middleware function
  • (C) A redirect code
  • (D) A request header

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ