Question 6
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
marks = 30
if marks >= 40:
result = "pass"
print("Result:", result)
- A NameError: result is assigned only when marks >= 40; on this path it was never created Correct
- B SyntaxError: result must be declared
- C It prints Result: None
- D It prints Result: pass
Correct Answer: Option A
Give it a value on every path: add else: result = "fail", or set result = "fail" before the if.
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!