0

program to find volume of the 1)sphere and 2) cylinder

5th Aug 2016, 5:06 PM
chetan wagadare
chetan wagadare - avatar
3 Antworten
0
import math pi = math.pi sphereRadius = float(input()) sphereVolume = (4/3)*pi*(sphereRadius)**3 print(sphereVolume thats for a sphere. the formula for a cylinder is V=pi*r^2*h you can easily change the code to work for a cylinder.
5th Aug 2016, 6:49 PM
Elias Grube
Elias Grube - avatar
0
radius = float(input()) height = float(input()) volume_of_cylinder = (1/3)*(22/7)*((radius)**2)*height volume_of_sphere = (4/3)* (22/7)*((radius)**3) print(volume_of_cylinder) print(volume_of_sphere)
5th Aug 2016, 7:10 PM
Pradeep Bilaiya
Pradeep Bilaiya - avatar
0
nice idea using 22/7 instead of pi. I didn't know that.
5th Aug 2016, 7:12 PM
Elias Grube
Elias Grube - avatar