Bird
0
0

Given the code:

medium📝 component behavior Q13 of 15
Flask - Performance Optimization
Given the code:
users = User.query.filter(User.age > 30).limit(5).all()

What does this query return?
AAll users older than 30
BFirst 5 users older than 30
C5 users regardless of age
DSyntax error due to filter condition
Step-by-Step Solution
Solution:
  1. Step 1: Analyze filter condition

    The filter selects users where age is greater than 30.
  2. Step 2: Understand limit effect

    The limit(5) restricts the result to the first 5 matching users.
  3. Final Answer:

    First 5 users older than 30 -> Option B
  4. Quick Check:

    Filter + limit = first 5 matching users [OK]
Quick Trick: Filter narrows data, limit caps number returned [OK]
Common Mistakes:
MISTAKES
  • Ignoring the limit and thinking all filtered users return
  • Confusing filter syntax with bitwise operator
  • Assuming limit applies before filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes