default parameters
Title
Question
What is the exact use of functions with default parameters in python?
Python-3.4.3 Advanced-Features-of-Functions 03-04 min 10-20 sec
Answers:
When a function is defined with default parameters like so
def myfunc(arg1, arg2=99, arg3='mystr'):
...
You can call the function such that you may or may not have to specify the arg2 and arg3 values
Hence all these are legal function calls for the above definition:
myfunc(22, 99, "new-string")
myfunc(22, 99)
myfunc(22)
Login to add comment