What are default arguments?



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.


def square_num (int a= 2 ):


    return s

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

Go Ad-free
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.