Task - 6 Given the following class, write the code for the Sphere and the Cylinder class so that the following output is printed. class Shape3D: OUTPUT: Shape name: Sphere, Area Formula: 4 * pi * r *...


Solve using Python3 and inheritance method


Task - 6<br>Given the following class, write the code for the Sphere and the Cylinder class so that<br>the following output is printed.<br>class Shape3D:<br>OUTPUT:<br>Shape name: Sphere, Area Formula: 4 * pi * r<br>* r<br>pi = 3.14159<br>def _init_(self, name =<br>self._area = 0<br>self._name = name<br>self._height = 'No need'<br>self._radius = radius<br>'Default', radius<br>0):<br>Radius: 5, Height: No need<br>Area: 314.159<br>====<br>=====<br>Shape name: Cylinder, Area Formula: 2 * pi<br>r * (r + h)<br>def calc_surface_area(self):<br>return 2 * Shape3D.pi * self._radius<br>Radius: 5, Height: 10<br>Area: 471.2385<br>def _str_(self):<br>return

Extracted text: Task - 6 Given the following class, write the code for the Sphere and the Cylinder class so that the following output is printed. class Shape3D: OUTPUT: Shape name: Sphere, Area Formula: 4 * pi * r * r pi = 3.14159 def _init_(self, name = self._area = 0 self._name = name self._height = 'No need' self._radius = radius 'Default', radius 0): Radius: 5, Height: No need Area: 314.159 ==== ===== Shape name: Cylinder, Area Formula: 2 * pi r * (r + h) def calc_surface_area(self): return 2 * Shape3D.pi * self._radius Radius: 5, Height: 10 Area: 471.2385 def _str_(self): return "Radius: "+str(self._radius) Sphere ('Sphere', 5) sph print('---- sph.calc_surface_area() print(sph) print('==== cyl = Cylinder('Cylinder', 5, 10) print(' cyl.calc_surface_area() print(cyl) - ')

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here