Exam-style question
Try this first
What is printed by this Python 3 code? def get_number(): return 8 print(get_number() + 2).
- A.2
- B.8
- C.10
- D.get_number() + 2
Answer and explanation
Concise answer
10
Why this is correct
The call to get_number() is replaced by its returned value, 8. The expression therefore becomes 8 + 2, which prints 10.
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.
