Q. Explain with a code example the usage of default arguments and keyword arguments.
Answer =
def interest (prin, cc, time = 2, rate = 0.09) :
return prin * time * rate
interest (prin = 300, cc = 5)
Here non default values provided as named argument.
interest (rate = 0.12, prin = 500, cc = 4)
Keyword argument can be used in any order and fir the argument skipped, there is a default value.
interest (cc = 4, rate = 0.12, prin = 500)
Here, with keyword argument, we can give values in any order.
Very very easy explanation
ReplyDelete: )
DeleteVery very easy explanation
ReplyDelete: )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )