0
program to find volume of the 1)sphere and 2) cylinder
3 odpowiedzi
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.
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)
0
nice idea using 22/7 instead of pi. I didn't know that.