Write a program in python to calculate volume of cylinder
Answers
The following codes must be typed in script mode, saved and then executed.
CODE 1:
pi = 3.14159r = int(input("Enter the radius of the cylinder:"))
h = int(input("Enter the height of the cylinder:"))
print("The volume of the cylinder is", pi*(r**2)*h)
OUTPUT:
5
12
CODE 2:
r = int(input("Enter the radius of the cylinder:"))
h = int(input("Enter the height of the cylinder:"))
vol = 3.14159*r**2*h
print("The volume of the cylinder is", vol)
OUTPUT:
5
12
Program to find the volume of the cylinder
A cylinder can be defined as the solid 3D object having two circular faces connected with the rectangular surface. The volume of the cylinder is the amount of space contained by it. The formula to calculate the volume of the cylinder is given below.
Formula
V=pie x r2 x h
where,
r is the radius of the cylinder
h is the height of the cylinder
V is the volume of the cylinder
Algorithm
Define the height of the cylinder.
Define the radius of the cylinder.
Calculate the volume of the cylinder pie x r2 x h
Define volume_cylinder and assign the volume of the cylinder to it.
Complexity