Python Unit - 4
Python Unit - 4
FUNCTION
Function is a block of code.
A large program divided into small program is called Output:
function.
Function is defined using the def keyword.
CREATING FUNCTION
The functions create using the keyword def.
Function must end with the colon (:).
Keyword cannot be used as function name.
Function name followed by the parenthesis ().
Parenthesis is used to pass the parameter or argument.
Syntax:
def function_name ():
#statement
Output:
Output:
Syntax:
reduce(function, iterable[,initializer])
Example:
return a + b
9. abs():
Returns the absolute value of a number.
10. round():
Rounds a number to a specified number of decimal places.