A function is a block of code to perform a specific task. A function consisting a group of statements to represent a specific task. The main objective of a function is to perform a task. If there are multiple tasks to be performed then we will define multiple functions. For example, to display output we write print(), to get current time we write time(), to get the power value, python has power() function. These functions are built in functions. Similarly the programmer can define his own functions which are known as user defined functions.
Actually the terminology function and method are same in python. Based on their placement we are saying somewhere is function and somewhere is method.
As we know a function is a block of code to perform a specified task. When a function is calling, then the function definition is executing. When we define a function it becomes a method in generally that we consider.
Method is called as:
Objectname.methodname()
Classname.methodname()
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc