logo

AQA A-Level Computer Science practice

What is printed by this Python 3 code? def get_number(): return 8 print(get_number() + 2)

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

What is printed by this Python 3 code? def get_number(): return 8 print(get_number() + 2).

  1. A.2
  2. B.8
  3. C.10
  4. 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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions