diferença entre método e função em pyhon
# What is Python Method ?
# Python Method
# 1.Method is called by its name, but it is associated to an object (dependent).
# 2.A method definition always includes ‘self’ as its first parameter.
# 3.A method is implicitly passed the object on which it is invoked.
# 4.It may or may not return any data.
# 5.A method can operate on the data (instance variables) that is contained
# by the corresponding class
# Basic Python Method Structure
class class_name
def method_name () :
......
# method body
......
# 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 :
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
Murad Ali