Bird
0
0

Given the Python function and test below, what will be the test result?

medium📝 Predict Output Q13 of 15
Testing Fundamentals - Testing Types and Levels
Given the Python function and test below, what will be the test result?
def multiply(a, b):
    return a * b

assert multiply(3, 4) == 12
assert multiply(0, 5) == 0
assert multiply(-1, 3) == -3
assert multiply(2, 2) == 5
AThe last assertion fails
BAll assertions pass
CThe first assertion fails
DThe second assertion fails
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate each assertion

    multiply(3,4) = 12 matches expected 12 (pass). multiply(0,5) = 0 matches 0 (pass). multiply(-1,3) = -3 matches -3 (pass). multiply(2,2) = 4 but expected 5 (fail).
  2. Step 2: Identify failing assertion

    The last assertion expects 5 but function returns 4, so it fails.
  3. Final Answer:

    The last assertion fails -> Option A
  4. Quick Check:

    4 != 5 causes failure [OK]
Quick Trick: Check each assert expected vs actual carefully [OK]
Common Mistakes:
  • Assuming all assertions pass without checking values
  • Confusing multiplication results
  • Ignoring the last assertion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes