Bird
0
0

Identify the error in this code:

medium📝 Debug Q7 of 15
Python - Conditional Statements

Identify the error in this code:

temperature = 30
if temperature > 25:
print("Hot")
elif temperature > 15:
    print("Warm")
AWrong comparison operator
BMissing colon after elif
CIndentation error in print("Hot")
DUsing elif without if
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation of print statements

    Python requires indented blocks after if and elif.
  2. Step 2: Identify print("Hot") is not indented

    Print under if is not indented, causing IndentationError.
  3. Final Answer:

    Indentation error in print("Hot") -> Option C
  4. Quick Check:

    Indent blocks after if/elif [OK]
Quick Trick: Indent code inside if and elif blocks properly [OK]
Common Mistakes:
MISTAKES
  • Not indenting code inside if or elif
  • Forgetting colon after elif
  • Using wrong operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes