Sphere

Report a typo

In her projects, Jess works with various geometrical objects. To simplify the process, she needs to create different classes for the shapes.

One of these shapes is a sphere. There are 3 characteristics she needs for the sphere: the PI number, the radius r and the volume v of the particular sphere.

The volume is calculated according to this formula: v=43πr3v = \frac {4}{3} \pi r^3.

Finish writing the code below: determine which attributes are class or instance attributes, and do necessary calculations. Make sure to name the attributes like they are presented above (that is, PI, radius, and volume.) Use π≈3.1415\pi \approx 3.1415 (for checkup purposes).

You do NOT need to create any instances of the class or work with input.

The constant can be stored as a class variable, the radius can be passed as a parameter to the __init__ method, and volume can be calculated within the __init__.

Write a program in Python 3
class Sphere:
# finish class Sphere here
...

Create a free account to access the full topic