CS FundamentalsVery hardProduct-company placement · ISTQB-style

For the function below, the tests (age = 30, member = True) and (age = 10, member = False) already give 100% statement and branch coverage. With short-circuit evaluation, which one extra test completes condition coverage?

For the function below, the tests (age = 30, member = True) and (age = 10, member = False) already give 100% statement and branch coverage. With short-circuit evaluation, which one extra test completes condition coverage?
def fee(age, member):
    f = 100
    if age < 12 or age > 60:
        f = 50
    if member:
        f = f - 20
    return f
  1. A. (age = 5, member = True)
  2. B. (age = 30, member = False)
  3. C. (age = 70, member = True)
  4. D. (age = 12, member = True)

Correct answer: C. (age = 70, member = True)

age > 60 has only been False (age 30); for age 10 it is skipped because age < 12 is already True. Only an age above 60 makes it True. Ages 5, 30 and 12 never make age > 60 True.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic