Professional Documents
Culture Documents
Module -4(function)
Module -4(function)
Module -4(function)
Function
Content
• Defining a Function
• Calling a Function
• Default Attribute Function
Function
function is a block of code which is used to perform particular task.
There are two types of function:-
1 Library or Inbuilt function
for example:-
print(),sum(),input() etc.
2 user defined function
There are four types of user defined function:-
User defined function
• There are four types of user defined function:-
1 No Argument No Return Type
2 With Argument No Return Type
3 No Argument with Return Type
4 With Argument with Return Type.
Declearation of function
• Syntax:-
def function_name(): // function declearation
Block of code
Function_name()// function calling
def mult():
n1=20
n2=10
multiply=n1*n2
return multiply
print("multiplication is :-",mult())
With Argument With Return Type
division of two numbers:
def div(a,b):
Div=a//b
return Div
z=div(20,10)
print(“division is ”,z)
Default Attribute Function
my_function("Sweden")
my_function(“Norway")
my_function()
my_function("Brazil")
Thank you