What is default argument? Explain with help of an example.
Answer
A default argument is a value provided in function header (declaration) which is automatically assigned by the interpreter if the caller of the function does not provide a value for the argument with a default value. For example
Write a python function to print the number of the digits in number. The function digit() will take the number as parameter and the number of digits one, two, three or more than three digits.
Write a function, on calling it will calculate the factorial of the integer passed as a parameter, and return this factorial. The function will not display anything but will simply return the calculated result.
eyword global is used to:(i) Specify the global variable(s) which will be used in the function even if their values are changed in the function.
(ii) To create global variable(s) in the function.