A dependent object is associated by method.It may or may not return any data.A method can operate on
the data as a instance variables that is contained by the corresponding class.
syntax :
class class_name def method_name () :
......
# method body
......
Functions:
Function is block of code that is also called by its name. The function can have different parameters
or may not have any at all. If any data as a parameters are passed ,It may or may not return any data.Function doesn't deal with class and its instance concept.
syntax :
def function_name ( arg1, arg2, ...) :
......
# function body
......
function and method both look similar. they perform in almost similar way, but the key difference is the concept of Class and Object.Functions can be called only by its name, But methods can’t be called by its name only, we need class by a reference of that class.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Python Method:
A dependent object is associated by method.It may or may not return any data.A method can operate on the data as a instance variables that is contained by the corresponding class.
syntax :
Functions:
Function is block of code that is also called by its name. The function can have different parameters or may not have any at all. If any data as a parameters are passed ,It may or may not return any data.Function doesn't deal with class and its instance concept.
syntax :
Difference between method and function :
function and method both look similar. they perform in almost similar way, but the key difference is the concept of Class and Object.Functions can be called only by its name, But methods can’t be called by its name only, we need class by a reference of that class.