Created
November 24, 2020 19:20
-
-
Save MLWhiz/56cb63cd7d45c54bb2545e7609b18ca2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
class Shape3d: | |
def __init__(self, name): | |
self.name = name | |
def surfaceArea(self): | |
pass | |
def volume(self): | |
pass | |
def getName(self): | |
return self.name | |
class Cuboid(Shape3d): | |
def __init__(self, name, length, breadth,height): | |
super().__init__(name) | |
self.length = length | |
self.breadth = breadth | |
self.height = height | |
def surfaceArea(self): | |
return 2*(self.length*self.breadth + self.breadth*self.height + self.length*self.height) | |
def volume(self): | |
return self.length*self.breadth*self.height | |
class Cube(Cuboid): | |
def __init__(self, name, side): | |
super().__init__(name,side,side,side) | |
class Sphere(Shape3d): | |
def __init__(self, name, radius): | |
super().__init__(name) | |
self.radius = radius | |
def surfaceArea(self): | |
return 4*pi*self.radius**2 | |
def volume(self): | |
return 4/3*pi*self.radius**3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment