The volume of a sphere is 4/3 pi r cube. write a function called print_volume(r) that takes an argument for the radius of the sphere and print the volume of the sphere. Call your print_volume function three times with different values for radius
def print_volume(r):
print('The volume of a sphere for radius',r,'is',
'{:.2f}'.format((4.0/3.0) * 3.1415926 * r * r * r))
print_volume(1)
print_volume(2)
print_volume(3.14)
Comments
Leave a comment