Tuesday, December 1, 2020

Difference between a Function and a Method in Python

 Difference between a Function and a Method in Python

* A function contains a group of statements and performs some specific task .This means that a function contains some set of statements , iterations and loops which help in formation of a function . Functions also help in performance of some specific tasks like execution of a set of codes or a batch of codes which might be intrinsic to the functioning of some machine or program . Also when a set of functions and codes collaborate with each other , a large scale project in the form of a compound body of code can be created which may have its own initiation and execution and termination .

* A function can be written individually in a Python Program . This means that a function can be written individually within a batch of Python programs as well which means that a program in Python (not only in Python but also in other Programming languages as well ) one can write a program in a suite which may stay isolated and individually or a Python program can also exist within a suite of other functions in a Program

* Method of calling a Python Program is by its name .

* Method of calling a Python Program is by its name.When a function is written inside a class , the function becomes a 'method' .

* A method can be called using the following ways :

objectname.methodname()

Classname.methodname()


* So , one may remember that a function and a method are the very same except the method of placement and the way the methods are called is also an intrinsic method of the way a method can be called .

* Creation of a function means defining a function or writing a function and once a function has been defined , it can be used by calling the function which can in the way presented in the above statements .

No comments:

Post a Comment