CS FundamentalsVery hardProduct-company MCQ pattern

Counting each simple condition in a compound boolean expression as a separate decision, what is the cyclomatic complexity of this function?

Counting each simple condition in a compound boolean expression as a separate decision, what is the cyclomatic complexity of this function?
def tally(a, b, items):
    count = 0
    for x in items:
        if x > a and x < b:
            count += 1
        elif x == 0 or x == -1:
            continue
    while count > 10:
        count -= 10
    return count
  1. A. 6
  2. B. 5
  3. C. 7
  4. D. 4

Correct answer: C. 7

Decisions: for (1), x > a and x < b (2), x == 0 or x == -1 (2), while (1) → 6, plus 1 = 7. Treating each compound condition as a single decision gives 5, the trap answer.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic