class Line:
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 (
(self.coor1[1] - self.coor2[1])
/(self.coor1[0] - self.coor2[0])
)
# EXAMPLE OUTPUT
coordinate1 = (3,2)
coordinate2 = (8,10)
li = Line(coordinate1,coordinate2)
li.distance()
9.433981132056603
li.slope()
1.6
Fill in the class
class Cylinder:
def __init__(self,height=1,radius=1):
self.height = height
self.radius = radius
def volume(self):
return 3.141592*self.radius**2*self.height
def surface_area(self):
return (
2*3.141592*self.radius*self.height
+ 2*3.141592*self.radius**2
)
# EXAMPLE OUTPUT
c = Cylinder(2,3)
c.volume()
56.548656
c.surface_area()
94.24776