In [5]:
class Line(object):
def __init__(self,coor1,coor2):
self.coor1 = coor1
self.coor2 = coor2
def distance(self):
return ((self.coor1[0] - self.coor2[0])**2 + (self.coor1[1] - self.coor2[1])**2)**(0.5)
def slope(self):
return float(self.coor1[1] - self.coor2[1])/(self.coor1[0] - self.coor2[0])
In [6]:
# EXAMPLE OUTPUT
coordinate1 = (3,2)
coordinate2 = (8,10)
li = Line(coordinate1,coordinate2)
In [7]:
li.distance()
Out[7]:
In [8]:
li.slope()
Out[8]:
Fill in the class
In [20]:
class Cylinder(object):
pi = 3.14
def __init__(self,height=1,radius=1):
self.height = height
self.radius = radius
def volume(self):
return Cylinder.pi*(self.radius**2)*self.height
def surface_area(self):
return 2*Cylinder.pi*self.radius*self.height + 2*Cylinder.pi*(self.radius**2)
In [22]:
# EXAMPLE OUTPUT
c = Cylinder(2,3)
In [23]:
c.volume()
Out[23]:
In [24]:
c.surface_area()
Out[24]:
In [ ]: