CS FundamentalsHardProduct-company MCQ pattern

What is the cyclomatic complexity of this function?

What is the cyclomatic complexity of this function?
def grade(m):
    if m >= 90:
        return "A"
    elif m >= 75:
        return "B"
    elif m >= 50:
        return "C"
    return "F"
  1. A. 3
  2. B. 4
  3. C. 1
  4. D. 5

Correct answer: B. 4

Three decision points (the if and two elifs) plus one: 3 + 1 = 4. Equivalently there are 4 independent paths, one per return. The final 'return F' is not a decision.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic