Functions · Class 11 · CBSE · Science Computer Science

What is the output of the following Python code? def product(a, b): return a b print(product(b=3, a=4))

Practice question from Functions (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-EC98DD

What is the output of the following Python code? def product(a, b): return a * b print(product(b=3, a=4))

  1. A.7
  2. B.12Correct answer
  3. C.43
  4. D.TypeError

Solution

The function call uses keyword arguments, so the values are assigned to the parameters by name. Therefore, product(b=3, a=4) returns 4 * 3, which is 12.

More from Functions

All of Functions

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed