logo

Question detail

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

Try the question, check the answer, then read the explanation to understand the curriculum point.

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

Model answer

What a good answer should say

  • 10

Explanation

Why this works

The call to get_number() is replaced by its returned value, 8. The expression therefore becomes 8 + 2, which prints 10.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.