Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pierian-data
GitHub Repository: pierian-data/complete-python-3-bootcamp
Path: blob/master/05-Object Oriented Programming/02-Object Oriented Programming Homework.ipynb
666 views
Kernel: Python 3


Content Copyright by Pierian Data

Object Oriented Programming

Homework Assignment

Problem 1

Fill in the Line class methods to accept coordinates as a pair of tuples and return the slope and distance of the line.

class Line: def __init__(self,coor1,coor2): pass def distance(self): pass def slope(self): pass
# EXAMPLE OUTPUT coordinate1 = (3,2) coordinate2 = (8,10) li = Line(coordinate1,coordinate2)
li.distance()
9.433981132056603
li.slope()
1.6

Problem 2

Fill in the class

class Cylinder: def __init__(self,height=1,radius=1): pass def volume(self): pass def surface_area(self): pass
# EXAMPLE OUTPUT c = Cylinder(2,3)
c.volume()
56.52
c.surface_area()
94.2