Bird
0
0

Find the error in this Python security test code:

medium📝 Debug Q6 of 15
Testing Fundamentals - Non-Functional Testing
Find the error in this Python security test code:
def test_authentication(user):
    if user.password == "secret":
    return True
    else:
        return False
AFunction missing return statement
BMissing colon after if statement
CIncorrect comparison operator
DIndentation error in return True line
Step-by-Step Solution
Solution:
  1. Step 1: Check Python indentation rules

    Python requires consistent indentation inside if blocks; return True is not indented properly.
  2. Step 2: Verify other syntax elements

    Colons are present, comparison operator is correct, and function returns values.
  3. Final Answer:

    Indentation error in return True line -> Option D
  4. Quick Check:

    Python blocks need proper indentation [OK]
Quick Trick: Indent inside if blocks in Python [OK]
Common Mistakes:
  • Ignoring indentation errors
  • Thinking colon is missing
  • Confusing == with =

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes