Home »
MCQs
Flask Multiple-Choice Questions (MCQs)
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries.
Flask MCQs: This section contains multiple-choice questions and answers on the various topics of Flask. Practice these MCQs to test and enhance your skills on Flask.
List of Flask MCQs
1. Flask framework is written in which of the following language?
- Java
- Python
- JavaScript
Answer: B) Python
Explanation:
The flask framework is written in python language.
Discuss this Question
2. Is Flask an open-source framework?
- Yes
- No
Answer: A) Yes
Explanation:
Flask framework is open-source.
Discuss this Question
3. Who developed the flask?
- Guido van Rossum
- Armin Ronacher
- James Gosling
Answer: B) Armin Ronacher
Explanation:
Armin Ronacher developed Flask.
Discuss this Question
4. Which is better Flask and Django?
- Flask
- Django
Answer: A) Flask
Explanation:
API support is provided by Flask; however, API support is not provided by Django.
Discuss this Question
5. By default, the flask server is ____?
- User-level thread
- Single-threaded
- multi-threaded
Answer: C) multi-threaded
Explanation:
By default, the flask server is multi-threaded.
Discuss this Question
6. Flask is reliant on which of the following?
- Jinja template
- Werkzeug WSGI framework
- Only A
- Only B
- Both A and B
- JavaScript
Answer: E) Both A and B
Explanation:
Flask is reliant on the Jinja template engine as well as the Werkzeug WSGI framework.
Discuss this Question
7. ____ is a framework for writing command line applications?
- MarkupSafe
- Jinja
- Click
Answer: C) Click
Explanation:
Click is a framework for writing command-line applications.
Discuss this Question
8. Which of the following dependency makes the development server's reloader quicker and more efficient in Flask?
- Blinker
- Watchdog
- Jinja
Answer: B) Watchdog
Explanation:
Watchdog makes the development server's reloader quicker and more efficient.
Discuss this Question
9. Flask is a framework for ____?
- Web development
- Mobile development
- Database development
- Cloud development
Answer: A) Web development
Explanation:
Flask framework is for web development.
Discuss this Question
10. What is WSGI in Flask?
- Wide system gateway interface
- Wide server gateway interface
- Web system gateway interface
- Web server gateway interface
Answer: D) Web server gateway interface
Explanation:
WSGI stands for Web server gateway interface
Discuss this Question
11. Which architecture does Flask follows?
- MVC
- MVP
- MVVM
Answer: A) MVC
Explanation:
Flask Framework follows MVC architecture.
Discuss this Question
12. Does the flask have a built in abstraction layer?
- Yes
- No
Answer: B) NO
Explanation:
Because Flask is a Micro Framework, it lacks a database abstraction layer.
Discuss this Question
13. ____ is a virtual Python environment builder?
- venv
- env
- virtualenv
Answer: C) virtualenv
Explanation:
virtualenv is a virtual Python environment builder.
Discuss this Question
14. The Flask class's ____function is a decorator that instructs the application which URL should call the related function?
- Route()
- Api()
- Name()
Answer: A) Route()
Explanation:
The Flask class's route() function is a decorator that instructs the application which URL should call the related function.
Discuss this Question
15. To run the application in Flask which of the following command is used?
- Run flask
- Run—flask
- Flask
- Start-pythonflask
Answer: C) Flask
Explanation:
To launch the application, use the flask command or python -m flask.
Discuss this Question
16. What is the default port for Flask?
- 8000
- 8080
- 3000
- 5000
Answer: D) 5000
Explanation:
The default port of Flask is 5000.
Discuss this Question
17. How do you start the development server in flask?
- Flask run
- RunFlask
- Run—
- FlaskRun--
Answer: A) Flask run
Explanation:
The flask run command starts the development server in the flask.
Discuss this Question
18. The project's endpoint's canonical URL has a ____ slash?
- Trailing
- Backward
Answer: A) Trailing
Explanation:
The project's endpoint's canonical URL has a trailing slash.
Discuss this Question
19. The ____method is quite handy for creating a URL for a given function dynamically?
- URL()
- Make_url()
- url_for()
- Create_url()
Answer: C) url_for()
Explanation:
The url_for() method is quite handy for creating a URL for a given function dynamically.
Discuss this Question
20. Which of the following method sends HTML form data to the server?
- Get
- Head
- Post
- Put
- Delete
Answer: C) Post
Explanation:
The post method sends HTML form data to the server.
Discuss this Question
21. Which of the following method replaces the submitted content with all current representations of the target resource?
- Get
- Head
- Post
- Put
- Delete
Answer: D) Put
Explanation:
The put method replaces the submitted content with all current representations of the target resource.
Discuss this Question
22. Which of the following method removes all existing representations of the resource specified by a URL?
- Remove
- Del
- Eliminate
- Delete
Answer: D) Delete
Explanation:
The delete method removes all existing representations of the resource specified by a URL.
Discuss this Question
23. Which of the following is the most often used approach and sends data to the server in an unencrypted format?
- Get
- Head
- Post
- Put
- Delete
Answer: A) Get
Explanation:
Get method is the most often used approach and sends data to the server in an unencrypted format.
Discuss this Question
24. Which of the following method is the same as the GET method but it does not have any response body?
- Get
- Head
- Post
- Put
- Delete
Answer: B) Head
Explanation:
The head method is the same as the GET method but it does not have any response body.
Discuss this Question
25. All the CSS and JavaScript files are stored in which of the following folder?
- Static
- Component
- Root
- Config
Answer: A) Static
Explanation:
Static folder contains CSS and JavaScript files.
Discuss this Question
26. Which of the following method is used to render a template?
- Render
- Template_render()
- Template
- Render_template()
Answer: D) Render_template()
Explanation:
To render a template you can use the render_template() method.
Discuss this Question
27. Flask will look in the ____folder for templates?
- Static
- Application
- Template
Answer: C) Template
Explanation:
Flask will look in the templates folder for templates.
Discuss this Question
28. To render the contents of a block defined in the parent template, which of the following function is used?
- {{ super() }}
- {{ parent }}
- Super {}
- {Body()}
Answer: A) {{ super() }}
Explanation:
To render the contents of a block defined in the parent template, use {{ super() }}.
Discuss this Question
29. The conditional statements if-else and endif are enclosed in delimiter ____?
- [%..%]
- (%..%)
- {%..%}
Answer: C) {%..%}
Explanation:
The conditional statements if-else and endif are enclosed in delimiter {%..%}.
Discuss this Question
30. Is it necessary to include enctype="multipart/form-data" in your form every time to upload files?
- Yes
- No
Answer: A) Yes
Explanation:
enctype="multipart/form-data" is important otherwise the browser will not transmit your files at all.
Discuss this Question
31. Which of the following attribute is used to gain access to cookies?
- Set
- Cookies
- Set_cookies
Answer: B) Cookies
Explanation:
The cookies attribute can be used to gain access to cookies.
Discuss this Question
32. Flask extensions are usually named ____?
- Flask-Foo
- Flask extension
- Flask
Answer: A) Flask-Foo
Explanation:
Flask extensions are usually named "Flask-Foo" or "Foo-Flask".
Discuss this Question
33. We Use the ____function to display a message?
- Display()
- Show()
- Flash()
- Message()
Answer: C) Flash()
Explanation:
We use the flash() function to display a message.
Discuss this Question
34. A common response format when writing an API is ____?
- JSON
- XML
- HTML
Answer: A) JSON
Explanation:
A common response format when writing an API is JSON.
Discuss this Question
35. Error code 429 is for ____.
- for Not Found
- for Unauthenticated
- Too Many Requests
Answer: C) Too Many Requests
Explanation:
Error code 429 means Too Many Requests.
Discuss this Question
36. We use the ____method to cancel a request with an error code?
- Cancel()
- Abort()
- Remove()
Answer: B) Abort()
Explanation:
We use the abort method to cancel a request with an error code.
Discuss this Question
37. Which of the following method is used to send a user to another endpoint?
- Direct()
- url()
- redirect()
- Page()
Answer: C) redirect()
Explanation:
Redirect() method to send a user to another endpoint.
Discuss this Question
38. To release a session variable which of the following method is used?
- Pop()
- Release()
- Post()
- Del()
Answer: A) Pop()
Explanation:
To release a session variable pop() method is used.
Discuss this Question
39. A ____is issued to each client session?
- Cookies
- Object
- Class
- Session ID
Answer: D) Session ID
Explanation:
A Session ID is issued to each client session.
Discuss this Question
40. A ____is the time interval between when a client logs into and logs off of a server?
- Cookies
- Assembly time
- Session
- Run
Answer: C) Session
Explanation:
A session is the time interval between when a client logs into and logs off of a server.
Discuss this Question
41. Session data is stored on ____?
- Server
- Client
Answer: B) Client
Explanation:
Session data is stored on the client.
Discuss this Question
42. Which of the following method of request.cookies attribute is used to read a cookie?
- Get
- Post
- Put
Answer: A) Get
Explanation:
The get() method of request.cookies attribute is used to read a cookie.
Discuss this Question
43. Which of the following extension sends mail to the users/clients?
- Mail
- Flask mail
- Mailtower
Answer: B) Flask mail
Explanation:
Flask mail extension sends mail to the users/clients.
Discuss this Question
44. Which of the following adds an attachment to a message?
- Add()
- Add_attachment()
- Addon()
- Attach()
Answer: D) Attach()
Explanation:
Attach() adds an attachment to the message.
Discuss this Question
45. We may specify the form fields in our Python script and present them using an HTML template using ____?
- Flask-form
- Flask-WTF
- Flask__forms
Answer: B) Flask-WTF
Explanation:
We may specify the form fields in our Python script and present them using an HTML template using Flask-WTF.
Discuss this Question
46. What Flask extension may be used to build an Ajax application?
- Flask Sijax
- Flask-WTF
- Flask-Ax
Answer: A) Flask Sijax
Explanation:
Flask Sijax extension may be used to build an Ajax application.
Discuss this Question
47. Sijax stands for ____.
- System Ajax
- Server Ajax
- Simple Ajax
Answer: C) Simple Ajax
Explanation:
Sijax stands for simple Ajax.
Discuss this Question
48. Which of the following extension create an Admin interface in Flask?
- Admin
- Flask-admin
- AdminFlask
Answer: B) Flask-admin
Explanation:
The flask-admin extension creates an Admin interface in Flask.
Discuss this Question
49. Sijax uses ____to pass the data between the browser and the server?
- Object
- XML
- HTML
- JSON
Answer: D) JSON
Explanation:
Sijax uses JSON to pass the data between the browser and the server.
Discuss this Question
50. Which of the following returns one row from the query?
- One()
- Fetchone()
- Fetchonly()
Answer: B) Fetchone()
Explanation:
fetchone() returns one row from the query.
Discuss this Question
51. session is a ____that stores data across requests?
- Dict
- Hash
- List
Answer: A) Dict
Explanation:
Session is a dict that stores data across requests.
Discuss this Question
52. ____ is another deployment option for Flask application on web servers like nginix, lighttpd, and Cherokee?
- Flask-WSGI
- Flask
- FastCGI
Answer: C) FastCGI
Explanation:
FastCGI is another deployment option for Flask applications on web servers like nginix, lighttpd, and Cherokee.
Discuss this Question
53. What is g in Flask?
- A global namespace for holding any data
- A local namespace for holding any data
Answer: A) A global namespace for holding any data
Explanation:
g in Flask is a global namespace for holding any data.
Discuss this Question
54. How do you obtain the HTTP headers in Flask?
- Headers
- Http.head
- Flask.request.head
- flask.request.headers
Answer: D) flask.request.headers
Explanation:
flask.request.headers helps us to obtain the HTTP headers in Flask.
Discuss this Question
55. How many types of data does a template have?
- 3
- 4
- 5
- 2
Answer: D) 2
Explanation:
The template contains two types of data: Static and dynamic.
Discuss this Question
56. A ____is a function that extends the functionality of another function without modifying it?
- Unit
- Module
- Decorator
- Component
Answer: C) Decorator
Explanation:
A decorator is a function that extends the functionality of another function without modifying it.
Discuss this Question
57. In Flask, how do you return JSON??
- Jason()
- Jasonify()
- Jason_object()
- Jason.flask
Answer: B) Jasonify()
Explanation:
Jasonify() function returns JSON.
Discuss this Question
58. Which of the following is a micro framework?
- Django
- Pyramid
- Flask
Answer: C) Flask
Explanation:
Flask is a micro framework.
Discuss this Question
59. How many ways are provided by flask to establish the database connection?
- 3
- 4
- 5
- 2
Answer: A) 3
Explanation:
Three ways are provided by flask to establish the database connection:
- Before_request()
- After_request()
- Teardown_ request()
Discuss this Question
60. Which of the following is the correct extension of Flask?
- .Flask
- .py
- .python
- .flask_python
Answer: B) .py
Explanation:
.py is the correct extension of the flask.
Discuss this Question