FastAPI MCQs

FastAPI MCQs: This section contains multiple-choice questions on FastAPI. All MCQs have the correct answers and explanations. These MCQs will help students and professionals to test their skills and to enhance their knowledge of FastAPI.

List of FastAPI MCQs

1. FastAPI is a ____.

  1. Java Web framework
  2. Python Web framework
  3. Ruby Web framework

Answer: B) Python Web framework

Explanation:

FastAPI is a modern Python web framework.

Discuss this Question


2. FastAPI is built on top of ____.

  1. Flask
  2. Django
  3. Starlette

Answer: C) Starlette

Explanation:

FastAPI is built on top of Starlette.

Discuss this Question


3. When FastAPI was developed?

  1. Jan 2015
  2. Dec 2019
  3. Dec 2020
  4. Dec 2018

Answer: D) Dec 2018

Explanation:

FastAPI was created in December 2018 by Sebastian Ramirez.

Discuss this Question


4. Which of the following is used to install FastAPI?

  1. pip3 install fastapi
  2. pip3 install Starlette-fastapi
  3. pip3 install fastapi- Starlette

Answer: A) pip3 install fastapi

Explanation:

"Pip3 install fastapi" is used to install FastAPI.

Discuss this Question


5. Is it important to install Starlette and Pydantic libraries with FastAPI?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Since FastAPI relies on the Starlette and Pydantic libraries, these are also installed.

Discuss this Question


6. Does FastAPI come with any built-in server application?

  1. Yes
  2. No

Answer: B) No

Explanation:

FastAPI doesn't come with any built-in server application.

Discuss this Question


7. To launch the FastAPI application, you'll require an ASGI server named ____.

  1. Uvicorn
  2. Unicorn
  3. Umicorn
  4. Uxicorn

Answer: A) Uvicorn

Explanation:

To launch the FastAPI application, you'll require an ASGI server named uvicorn.

Discuss this Question


8. What is ASGI?

  1. Asynchronous System Gateway Interface
  2. Application Server Gateway Interface
  3. Application System Gateway Interface
  4. Asynchronous Server Gateway Interface

Answer: D) Asynchronous Server Gateway Interface

Explanation:

ASGI stands for Asynchronous Server Gateway Interface.

Discuss this Question


9. What is the full form of WSGI?

  1. Web Socket Gateway Interface
  2. Web Shift Gateway Interface
  3. Web Server Gateway Interface

Answer: C) Web Server Gateway Interface

Explanation:

WSGI stands for Web Server Gateway Interface.

Discuss this Question


10. A ____ is the section of the URL that comes after the initial '/'.

  1. Channel
  2. Unit
  3. Route

Answer: C) Route

Explanation:

A path or route is the section of the URL that comes after the initial '/'.

Discuss this Question


11. Which keyword in the function's definition tells FastAPI that it is to be run asynchronously?

  1. Asyn
  2. Async
  3. Asyncho
  4. All of the above

Answer: B) Async

Explanation:

The async keyword in the function's definition tells FastAPI that it is to be run asynchronously.

Discuss this Question


12. You must import the ____ in order to apply the validation requirements to a path argument.

  1. Parameter class
  2. Validate class
  3. Validation class
  4. Path class

Answer: D) Path class

Explanation:

You must import the Path class in order to apply the validation requirements to a path argument.

Discuss this Question


13. Which of the following is a Python data parsing and validation library.

  1. Pydantic
  2. PyOpe
  3. Schema
  4. Marshmello

Answer: A) Pydantic

Explanation:

Pydantic is a Python data parsing and validation library.

Discuss this Question


14. Pydantic will convert data types automatically whenever feasible.

  1. True
  2. False

Answer: A) True

Explanation:

Pydantic will convert data types automatically whenever feasible.

Discuss this Question


15. FastAPI sends a ____ response to the client by default

  1. HTML
  2. CSV
  3. JSON

Answer: C) JSON

Explanation:

FastAPI sends a JSON response to the client by default.

Discuss this Question


16. FastAPI has a which class to process the data received as a request by submitting an HTML form?

  1. HTML-FORM CLASS
  2. FORM CLASS
  3. HTML CLASS

Answer: B) FORM CLASS

Explanation:

FastAPI has a Form class to process the data received as a request by submitting an HTML form.

Discuss this Question


17. ____ is the process through which an item obtains other objects on which it depends.

  1. Refactoring dependency
  2. Dependency injection
  3. Coupling

Answer: B) Dependency injection

Explanation:

Dependency injection is the process through which an item obtains other objects on which it depends.

Discuss this Question


18. Which of the following is an advantage of dependency injection?

  1. Reuse shared functionality
  2. Share database connections
  3. Authentication and security requirements.
  4. All of the above

Answer: D) All of the above

Explanation:

Following are the advantages of dependency injection:

  • Reuse shared functionality
  • Share database connections
  • Authentication and security requirements

Discuss this Question


19. What is the full form of CORS?

  1. Combine-Origin Resource Sharing
  2. Combine-Origin Resource System
  3. Cross-Origin Resource Sharing

Answer: C) Cross-Origin Resource Sharing

Explanation:

CORS stands for Cross-Origin Resource Sharing.

Discuss this Question


20. Which of the following statement is correct?

  1. Cross-Origin Resource Sharing (CORS) is a circumstance in which a backend program running on a different client browser attempt to connect with a frontend using HTML code, but the frontend is in a different "origin" than the backend.
  2. Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.

Answer: B) Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.

Explanation:

Statement B is correct, Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.

Discuss this Question


21. ____ is a programming technique for converting data between incompatible type systems in object-oriented programming languages.

  1. OOP
  2. Functional programming
  3. ORM
  4. AOP

Answer: C) ORM

Explanation:

Object Relational Mapping is a programming technique for converting data between incompatible type systems in object-oriented programming languages.

Discuss this Question


22. Does FastAPI uses NoSQL DB?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

FastAPI can also leverage NoSQL databases like MongoDB, Cassandra, CouchDB, and others as the backend for REST app CRUD operations.

Discuss this Question


23. A ____ is a persistent connection that allows bidirectional, full-duplex communication between a client and a server.

  1. Web Servlet
  2. WebSocket
  3. WebGL

Answer: B) WebSocket

Explanation:

A WebSocket is a persistent connection that allows bidirectional, full-duplex communication between a client and a server.

Discuss this Question


24. Which of the following is the HTTP's disadvantages?

  1. One of HTTP's disadvantages is that it is just a full-duplex or directional protocol.
  2. One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.

Answer: B) One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.

Explanation:

One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.

Discuss this Question


25. WebSockets are supported by FastAPI via the ____ class in the FastAPI module.

  1. Web class
  2. Sockets class
  3. WebGL class
  4. WebSockets class

Answer: D) WebSockets class

Explanation:

WebSockets are supported by FastAPI via the WebSocket class in the FastAPI module.

Discuss this Question


26. Does FastAPI supports asynchronous requests?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, FastAPI supports asynchronous requests, which can help your application run better.

Discuss this Question


27. Which of the following is a decorator used to specify a FastAPI route or endpoint? It is used to link a function to a certain HTTP request method (such as GET, POST, PUT, DELETE, and so on) and URL path.

  1. @app.router()
  2. @app.route_engine()
  3. @app.route()

Answer: C) @app.route()

Explanation:

@app.route() is a decorator used to specify a FastAPI route or endpoint. It is used to link a function to a certain HTTP request method (such as GET, POST, PUT, DELETE, and so on) and URL path.

Discuss this Question


28. Which of the following is a decorator for defining a route or endpoint that handles GET requests?

  1. @app.getter()
  2. @app.get()
  3. @app.get_request()

Answer: B) @app.get()

Explanation:

@app.get() is a decorator for defining a route or endpoint that handles GET requests.

Discuss this Question


29. To create a middleware you use which decorator?

  1. @app.middleware("http")
  2. @app.middle_route("http").
  3. @app.middleware_engine("http").

Answer: A) @app.middleware("http")

Explanation:

To create a middleware you use the decorator @app.middleware("http").

Discuss this Question


30. Which of the following refers to the addition of a complete "independent" application in a specified route, which subsequently handles all sub-paths?

  1. Casing
  2. Clamping
  3. Coupling
  4. Mounting

Answer: D) Mounting

Explanation:

"Mounting" refers to the addition of a complete "independent" application in a specified route, which subsequently handles all sub-paths.

Discuss this Question


31. Which of the following statement is True?

  1. A request body is data sent by the client to your API. A response body is the data your API sends to the client.
  2. A response body is data sent by the client to your API. A request body is the data your API sends to the client.

Answer: A) A request body is data sent by the client to your API. A response body is the data your API sends to the client.

Explanation:

Statement A is correct; a request body is data sent by the client to your API. A response body is the data your API sends to the client.

Discuss this Question


32. ____ is used to return HTTP replies with problems to the client.

  1. RouterException
  2. PathException
  3. HTTPException

Answer: C) HTTPException

Explanation:

HTTPException is used to return HTTP replies with problems to the client.

Discuss this Question


33. Which of the following middleware's are available in the FastAPI library?

  1. CORSMiddleware
  2. HTTPSRedirectMiddleware
  3. TrustedHostMiddleware
  4. GZipMiddleware
  5. All of the above

Answer: E) All of the above

Explanation:

Following are some of the middleware available in the FastAPI library:

  • CORSMiddleware
  • HTTPSRedirectMiddleware
  • TrustedHostMiddleware
  • GZipMiddleware

Discuss this Question


34. ____ are used to specify routes in FastAPI.

  1. Annotations
  2. Type Hinting
  3. Decorators

Answer: C) Decorators

Explanation:

Decorators are used to specify routes in FastAPI.

Discuss this Question


35. Can we use FastAPI to upload files?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, you can use FastAPI to upload files. There are several approaches, but the most typical is to utilize the FileUpload class.

Discuss this Question




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.