Bird
0
0

A test plan states: approach = 'exploratory' but the code uses if approach = 'exploratory':. What is the error and how to fix it?

medium📝 Debug Q14 of 15
Testing Fundamentals - Testing Models and Approaches
A test plan states: approach = 'exploratory' but the code uses if approach = 'exploratory':. What is the error and how to fix it?
ASyntaxError due to '=' instead of '==' in if condition; fix by using '=='
BLogical error; no fix needed
CRuntime error because 'approach' is undefined
DNo error; code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Identify the error in the if statement

    The code uses '=' (assignment) inside the if condition, which is invalid syntax in Python.
  2. Step 2: Correct the syntax for comparison

    Replace '=' with '==' to compare values properly.
  3. Final Answer:

    SyntaxError due to '=' instead of '==' in if condition; fix by using '==' -> Option A
  4. Quick Check:

    Use '==' for comparison in conditions [OK]
Quick Trick: Use '==' for comparisons, '=' for assignments [OK]
Common Mistakes:
  • Using '=' in if condition
  • Ignoring syntax errors
  • Confusing assignment with comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes