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- A. (age = 5, member = True)
- B. (age = 30, member = False)
- C. (age = 70, member = True)
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- McCabe's V(G) = E - N + 2 for one function comes from the cyclomatic number of a strongly connected graph, E - N + P. Where does the '+2'…
- A loan is approved if (salary ≥ ₹50,000 AND credit history is good) OR a guarantor is provided. Using a limited-entry decision table with…
- An ATM state machine: inserting a card leads to '1st try'. A correct PIN in any try state leads to 'Access'; a wrong PIN moves 1st → 2nd →…
- A price field accepts amounts from ₹0.01 to ₹999.99, with exactly two decimal places. Which pair of values are the invalid boundary values…
- For the function below, what are its cyclomatic complexity and the number of times a[j] > a[j + 1] is evaluated for the input [2, 1, 3, 4…
- Assertion (A): A suite with 100% branch coverage can still miss a defect where a required check was never coded. Reason (R): White-box…