Advertisement
Radeen10-_

Example of Super Class in Python

Aug 16th, 2021
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1.  
  2. Find the total surface area of a regular pyramid with a square base if each edge of the base measures 16 inches, the slant height of a side is 17 inches and the altitude is 15 inches.
  3. Ans of the total surface area will be 800
  4. -------------------------------------------------------------------------------------------------------------------------------------
  5.  
  6.  
  7. class Triangle:
  8.     def __init__(self,base,slant_height):
  9.         self.base=base
  10.         self.slant_height=slant_height
  11.     def perimeter(self):
  12.         return 4*self.base
  13.     def area(self):
  14.         return self.base*self.base
  15. class Pyramid(Triangle):
  16.     def __init__(self,base,slant_height):
  17.         super().__init__(base,slant_height)
  18.     def total_surface_area(self):
  19.         base_area=super().area()
  20.         perimeter=super().perimeter()
  21.         return 0.5*perimeter*self.slant_height+base_area
  22. pyramid=Pyramid(16,17)
  23. print(pyramid.total_surface_area())
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement