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")
Answer and explanation
Concise answer
if score >= 50: print("Pass") else: print("Try again")
Why this is correct
The Python code uses the comparison operator >=, a colon after each condition, indentation for each branch, and outputs the same messages as the pseudocode.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
