Fast API MCQs with answers Page - 18

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.96K Points
Extraordinary

Q. Which file type can be uploaded using `UploadFile` in FastAPI?

  • (A) Only .txt files
  • (B) Only image files
  • (C) Only JSON files
  • (D) Any file type

R

Ravina • 3.96K Points
Extraordinary

Q. Which method is used to mount sub-applications in FastAPI?

  • (A) use_subapp()
  • (B) add_subapp()
  • (C) mount()
  • (D) bind_app()

R

Ravina • 3.96K Points
Extraordinary

Q. Which parameter in `Query()` restricts values to a set of choices?

  • (A) options
  • (B) enum
  • (C) choices
  • (D) allowed

R

Ravina • 3.96K Points
Extraordinary

Q. How does FastAPI detect whether a parameter is a path, query, or body parameter?

  • (A) Using parameter name
  • (B) Using position in function signature
  • (C) Using type hint and default value
  • (D) Using runtime introspection

R

Ravina • 3.96K Points
Extraordinary

Q. How can you modify the title of the OpenAPI docs in FastAPI?

  • (A) app.settings.title = 'New Title'
  • (B) app.openapi_title = 'New Title'
  • (C) FastAPI(title='New Title')
  • (D) app.docs_title = 'New Title'

R

Ravina • 3.96K Points
Extraordinary

Q. How can you provide custom exception handling in FastAPI?

  • (A) By overriding `handle_exception()`
  • (B) By using Flask errorhandler
  • (C) By using `@app.exception_handler()`
  • (D) By setting `raise_on_error=True`

R

Ravina • 3.96K Points
Extraordinary

Q. What does the parameter `description` in `Query()` do?

  • (A) Validates the length
  • (B) Shows extra info in OpenAPI docs
  • (C) Prevents empty values
  • (D) Sets default fallback values

R

Ravina • 3.96K Points
Extraordinary

Q. What is `FormData` used for in FastAPI?

  • (A) To receive JSON requests
  • (B) To serve HTML content
  • (C) To parse x-www-form-urlencoded data
  • (D) To send files

R

Ravina • 3.96K Points
Extraordinary

Q. What does `status_code=204` represent in FastAPI?

  • (A) Bad request
  • (B) No content
  • (C) Created
  • (D) Reset content

R

Ravina • 3.96K Points
Extraordinary

Q. What does `BaseSettings` class in FastAPI provide?

  • (A) WebSocket interface
  • (B) CORS management
  • (C) Environment variable support using Pydantic
  • (D) Database transaction manager

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