0
0
Flaskframework~20 mins

Flask vs Django decision - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flask vs Django Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Choosing Flask or Django for a small project

You want to build a simple web app with a few pages and minimal database use. Which framework is better suited for quick setup and flexibility?

AFlask, because it is lightweight and lets you add only what you need.
BDjango, because it has many built-in features and enforces structure.
CDjango, because it requires less coding for small projects.
DFlask, because it automatically generates admin interfaces.
Attempts:
2 left
💡 Hint

Think about which framework is minimal and flexible for small apps.

component_behavior
intermediate
2:00remaining
How Django handles database migrations compared to Flask

Which statement correctly describes how Django and Flask handle database schema changes?

AFlask has built-in migration tools that automatically update the database schema.
BDjango requires manual SQL scripts for every schema change.
CDjango uses built-in migration tools to track and apply schema changes automatically.
DFlask automatically detects and applies schema changes without extra setup.
Attempts:
2 left
💡 Hint

Consider which framework includes built-in tools for database migrations.

📝 Syntax
advanced
2:00remaining
Identifying correct Flask route syntax

Which Flask route definition will correctly respond to GET requests at URL '/hello'?

Flask
from flask import Flask
app = Flask(__name__)

@???
def hello():
    return "Hello!"
A@app.route('/hello', method='GET')
B@app.route('/hello', methods='GET')
C@app.route('/hello', get=True)
D@app.route('/hello', methods=['GET'])
Attempts:
2 left
💡 Hint

Check the correct keyword and value type for specifying HTTP methods in Flask routes.

state_output
advanced
2:00remaining
Django template rendering output

Given this Django template snippet and context, what will be the rendered output?

Flask
{% if user.is_authenticated %}
  Welcome, {{ user.username }}!
{% else %}
  Please log in.
{% endif %}
AWelcome, alice!
BPlease log in.
CWelcome, {{ user.username }}!
DError: user is not defined
Attempts:
2 left
💡 Hint

Assume the context has user.is_authenticated = True and user.username = 'alice'.

🔧 Debug
expert
2:00remaining
Debugging Flask app context error

What error will this Flask code raise when trying to access request.args outside a request context?

Flask
from flask import Flask, request
app = Flask(__name__)

print(request.args)
ANo error, prints an empty ImmutableMultiDict.
BRuntimeError: Working outside of request context.
CNameError: name 'request' is not defined.
DAttributeError: 'NoneType' object has no attribute 'args'.
Attempts:
2 left
💡 Hint

Think about when Flask's request object is available.