CBSE Class 12 Computer Science Question 30 of 103

Working with Functions — Question 6

Back to all questions
6
Question

Question 6

Which of the following function headers is correct ?

  1. def f(a = 1, b):
  2. def f(a = 1, b, c = 2):
  3. def f(a = 1, b = 1, c = 2):
  4. def f(a = 1, b = 1, c = 2, d):
Answer

def f(a = 1, b = 1, c = 2):

Reason — In a function header, any parameter cannot have a default value unless all parameters appearing on its right have their default values.