Class
class ClassName:
'Optional Class documentation string'
class_suit
Following is the example of a simple Python Class
class Circle:
'Class for Circle. Can be used to find area and perimeter'
pi = 3.14
def __init__(self,radius):
self.radius = radius
def area(self):
return Circle.pi * self.radius * self.radius
def peri(self):
return 2 * self.__class__.pi * self.radius
a = Circle(40)
print(a.radius)
print(a.area())
print(a.peri())
print a.pi
class Man:
def __init__(self,name,age,sex,weight,height):
self.name = name
self.age = age
self.sex = sex
self.weight = weight
self.height = height
a = Man('jeeva',40,'male',140,160)