home

Scientific Computing (Psychology 9040a)

Fall, 2021

Volume of a sphere


The volume \(v\) of a sphere with radius \(r\) is given by:

\[\begin{equation} v = \frac{4}{3} \pi r^{3} \end{equation}\]

Write a short program to calculate the volume of a sphere with radius \(5\). You can approximate the value of \(\pi\) as \(3.14\).


sample solution