LearnFrenzy
Sign in Take a free test

Conditional Statements · Find the Error · Question 7

Bug: the topper is graded as a pass Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

A student with 95 marks should get "Distinction". Which statement correctly identifies the bug?

main.py
marks = 95
if marks >= 40:
    print("Pass")
elif marks >= 75:
    print("First class")
elif marks >= 90:
    print("Distinction")
  • A elif should be else if
  • B The broadest condition (>= 40) is tested first, so the more specific branches are never reached; order them from highest to lowest Correct
  • C marks must be a float
  • D The last branch needs else
Correct Answer: Option B

Only the first true branch runs. Test >= 90, then >= 75, then >= 40.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links