Skip to main content

Posts

Showing posts with the label volume of sphere python

volume of sphere and hemisphere in Python | program

 volume of sphere and hemisphere. Volume  of  hemisphere  = 2πr 3 /3, where 'r' is the radius of the  hemisphere . Volume  of  sphere  = 4πr 3 /3, where 'r' is the radius of the  sphere . Program to find volume of sphere and hemisphere Input : enter radius of sphere 4 enter radius of hemisphere 4 Output : volume of sphere is %.2f 268.08 volume of hemisphere is 134.04 # Program to find volume of sphere and hemisphere # for pi use pi value as 3.1423 or import math module from math import* #Program to find volume of sphere radius1 = float(input("enter radius of sphere ")) vol_sphere = (4*pi*radius1*radius1*radius1)/3 print("volume of sphere is %.2f",round(vol_sphere,2)) #Program to find volume of hemisphere radius2 = float(input("enter radius of hemisphere ")) vol_hemisphere = (2*pi*radius2*radius2*radius2)/3 print("volume of hemisphere is ",round(vol_hemisphere,2)) #here round(var,n) is predefined function used to get n digits afte...