Exam-style question
Try this first
Which Python code correctly implements this pseudocode? IF score >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Try again" ENDIF.
- A.if score >= 50: print("Pass") else: print("Try again")
- B.if score = 50: print("Pass") else: print("Try again")
- C.if score >= 50 print("Pass") else print("Try again")
- D.if score >= 50: print("Try again") else: print("Pass")
Model answer
What a good answer should say
- if score >= 50: print("Pass") else: print("Try again")
Explanation
Why this works
The Python code uses the comparison operator >=, a colon after each condition, indentation for each branch, and outputs the same messages as the pseudocode.
Common mistake
No common mistake is linked to this question yet.
