Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Python - Conditional Statements

Identify the error in this code snippet:

temperature = 75
if temperature > 80
    print("Hot")
elif temperature >= 60:
    print("Warm")
AIncorrect indentation of print statements
BMissing colon after if condition
CUsing >= instead of > in elif
DMissing else statement
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of if statement

    The if condition 'if temperature > 80' is missing a colon at the end.
  2. Step 2: Verify other parts

    Indentation and elif condition are correct. Else is optional.
  3. Final Answer:

    Missing colon after if condition -> Option B
  4. Quick Check:

    Colon required after if condition [OK]
Quick Trick: Always put colon after if condition [OK]
Common Mistakes:
MISTAKES
  • Forgetting colon after if or elif
  • Incorrect indentation
  • Assuming else is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes