Python Method
- Method is called by its name, but it is associated to an object (dependent).
- A method is implicitly passed the object on which it is invoked.
- It may or may not return any data.
- A method can operate on the data (instance variables) that is contained by the corresponding class
- Function is block of code that is also called by its name. (independent)
- The function can have different parameters or may not have any at all. If any data (parameters) are passed, they are passed explicitly.
- It may or may not return any data.
- Function does not deal with Class and its instance concept.
- Simply, function and method both look similar as they perform in almost similar way, but the key difference is the concept of ‘Class and its Object‘.
- Functions can be called only by its name, as it is defined independently. But methods can’t be called by its name only, we need to invoke the class by a reference of that class in which it is defined, i.e. method is defined within a class and hence they are dependent on that class.