Last Updated : 11 Jul, 2025
Here, key differences between Method and Function in Python are explained. Java is also an OOP language, but there is no concept of Function in it. But Python has both concept of Method and Function.
Python Method
Basic Method Structure in Python :
Python
# Basic Python method
class class_name
def method_name () :
......
# method body
......
Python 3 User-Defined Method :
Python3
# Python 3 User-Defined Method
class ABC :
def method_abc (self):
print("I am in method_abc of ABC class. ")
class_ref = ABC() # object of ABC class
class_ref.method_abc()
Output:
I am in method_abc of ABC class
Python 3 Inbuilt method :
Python3
import math
ceil_val = math.ceil(15.25)
print( "Ceiling value of 15.25 is : ", ceil_val)
Output:
Ceiling value of 15.25 is : 16
Know more about Python ceil() and floor() method.
Functions
Basic Function Structure in Python :
Python3
def function_name ( arg1, arg2, ...) :
......
# function body
......
Python 3 User-Defined Function :
Python3
def Subtract (a, b):
return (a-b)
print( Subtract(10, 12) ) # prints -2
print( Subtract(15, 6) ) # prints 9
Output:
-2 9
Python 3 Inbuilt Function :
Python3
s = sum([5, 15, 2])
print( s ) # prints 22
mx = max(15, 6)
print( mx ) # prints 15
Output:
22 15
Know more about Python sum() function. Know more about Python min() or max() function.
Difference between method and function
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4