Given sphereradius and pival, compute the volume of a sphere and assign to spherevolume. use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division. volume of sphere = (4.0 / 3.0) π r3 (hint: r3 can be computed using *)

Respuesta :

The volume of a sphere is

[tex] \dfrac{4}{3} \pi r^3 [/tex]

As the hint suggests, we can avoid the use of powers, if we recall that

[tex] r^3 = r \cdot r \cdot r [/tex]

So, we can rewrite the volume as

[tex] \dfrac{4}{3} \pi r \cdot r \cdot r [/tex]

Since we're given two variables storing the values of [tex] \pi [/tex] and the radius, we can write the line of code as follows:

spherevolume = (4.0 / 3.0) * pival * sphereradius * sphereradius * sphereradius ;

fichoh

The program which computes the volume of a sphere written in python 3 goes thus :

  • spherevolume = (4.0/3.0)*pival*(sphereradius)**3

sphereradius = r

pival = 3.142

The formula for obtaining the volume of a sphere can be expressed thus :

  • Volume = (4.0/3.0) × πr³

Hence, using Python :

spherevolume = (4.0/3.0)*pival*(sphereradius)**3

print(spherevolume)

# displays the calculated volume of the sphere based on the value of the Radius supplied.

Learn more :https://brainly.com/question/2800358