What are default arguments?

 

Answer:

Default arguments in python are those arguments that get assigned a default value if no explicit values are passed to these arguments in the function call.

Example:

def square_num (int a= 2 ):

    s=a*a

    return s

If a value is not passed when the above function is invoked, then, by default, ‘a’ gets assigned the value 2.

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.