Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Python - Conditional Statements
What will be the output of this code?
age = 25
has_passport = True
if age > 18 and has_passport:
    print('Allowed')
else:
    print('Denied')
ADenied
BAllowed
CSyntax Error
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate conditions

    age > 18 is true (25 > 18), has_passport is true.
  2. Step 2: Apply 'and' operator

    true and true is true, so the if block runs.
  3. Final Answer:

    Allowed -> Option B
  4. Quick Check:

    true and true = true [OK]
Quick Trick: Both conditions must be true for 'and' to pass [OK]
Common Mistakes:
MISTAKES
  • Misreading boolean values
  • Confusing 'and' with 'or'
  • Ignoring indentation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes