Bird
0
0

Consider this code snippet for a simple test check:

medium📝 Predict Output Q13 of 15
Testing Fundamentals - Why Software Testing Matters
Consider this code snippet for a simple test check:
def test_sum():
    result = 2 + 2
    assert result == 4
    print('Test passed')

What will be the output when this test runs?
ATest passed
BAssertionError
CNo output
DSyntaxError
Step-by-Step Solution
Solution:
  1. Step 1: Check the assertion condition

    The sum 2 + 2 equals 4, so assert result == 4 passes.
  2. Step 2: Determine output after assertion

    Since assertion passes, 'Test passed' is printed.
  3. Final Answer:

    Test passed -> Option A
  4. Quick Check:

    2+2=4, assertion passes, print runs [OK]
Quick Trick: If assert condition is true, print statement runs [OK]
Common Mistakes:
  • Thinking assertion fails causing error
  • Expecting no output from print
  • Confusing syntax errors with assertion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes