KnowledgeBoat Logo
|

Computer Science

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):

Python Functions

18 Likes

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.

Answered By

4 Likes


Related Questions