Write a function called print_voluma (r) that takes an argument for radius of the sphere, and prints the volume of the sphere .
Call your print_volume function three times with different values for radius .
Include all the following in your learning Journal :
· The code for your print_volume function.
·The inputs and outputs of three calls of your print_volume
import math
_pi = math.pi
def print_volume (rad):
res = (4 / 3) * _pi * (rad * rad *rad)
return res
print("volume of the sphere (radius=7) = ",print_volume(7))
print("volume of the sphere (radius=14) = ",print_volume(14))
print("volume of the sphere (radius=21) = ",print_volume(21))
Comments
Leave a comment