Bird
0
0

What is the output of this code?

medium📝 Predict Output Q13 of 15
Python - Conditional Statements
What is the output of this code?
age = 20
status = "Adult" if age >= 18 else "Minor"
print(status)
AAdult
BMinor
CTrue
DFalse
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition

    The condition age >= 18 is True because age is 20.
  2. Step 2: Determine the value assigned

    Since condition is True, status is assigned "Adult".
  3. Final Answer:

    Adult -> Option A
  4. Quick Check:

    age 20 >= 18 is True, so status = Adult [OK]
Quick Trick: Check condition result first, then pick value before else [OK]
Common Mistakes:
MISTAKES
  • Choosing the else value instead of the if value
  • Confusing string output with boolean
  • Ignoring the condition result

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes