+ 3
What is the difference between a "function" and a "method"?
5 odpowiedzi
+ 8
In PYTHON:
A function is a callable object and a method is special class of function.
--Clear Concept--
Function:
A keyword which do any function like input and output.
e.g "print" is a function, which shows the output in it's blocks.
Method:
A keyword which do a procedure on any class, object, arguments like finding maximum and minimum.
e.g "len" is method which do a procedure on variable having items and return it's items. i.e len(a)
+ 3
I'd would add that a function has kind of a global scope in the sense that can be accessed anywhere. But methods are tied to the class where is defined. So, methods have a more limited scope and that is a good thing. Limiting the scope is the core of object programming. You can call a method with the same name on different objects and have its own custom behaviour for each one.
0
Good Answer Shahid Islam.
Deserve Upvote
0
a function is created by you to execute codes..
a method is a pre-set function that have its own rules and codes and are created for complicated operation
0
Thankyou Salman Tiwana