Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
Python - Operators and Expression Evaluation
Find the error in this code snippet:
num1 = 10
num2 = 5
result = num1 -+ num2
print(result)
AThe operator '-+' is invalid
BVariables are not defined
CMissing print statement
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Identify the operator used

    The code uses '-+' which is not a valid operator in Python.
  2. Step 2: Understand correct operator usage

    To subtract, use '-' alone. '-+' is a syntax error.
  3. Final Answer:

    The operator '-+' is invalid -> Option A
  4. Quick Check:

    Invalid operator '-+' causes error [OK]
Quick Trick: Check operators carefully for invalid symbols [OK]
Common Mistakes:
MISTAKES
  • Mixing two operators together
  • Assuming '-+' means subtract then add
  • Ignoring syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes