Python Flask Flashcards

1
Q

What is a major advantage of Python being a dynamically typed language?

A

It increases flexibility and reduces lengthy coding requirements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of a virtual environment (venv) in Python?

A

To create isolated environments for Python projects, ensuring different projects have their own dependencies and settings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Flask?

A

A micro web framework for Python.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you install Flask in a virtual environment?

A

“pip install Flask”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which decorator is used to define a route in a Flask application?

A

@app.route

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q7: In the given Flask code snippet, what is the purpose of the jsonify function?
“@app.route(“/books”, methods=[“GET”])
def get_books():
return jsonify(books)

A

To convert Python objects into a JSON response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you start a Flask application defined in hello.py?

A

flask –app hello run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which HTTP method is used to create a new resource in a RESTful service with Flask?

A

POST

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What HTTP status code is returned when a new resource is successfully created in a RESTful API?

A

201 Created

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you update an existing resource in a RESTful API with Flask?

A

Use the PUT method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly