In this python program, we will learn how to calculate the volume and surface area of a cone. In this program, we will use the python built-in math.sqrt() function to calculate the square root of the number and this math.sqrt() function belongs to the math module of the python.
A cone is a three-dimensional geometric shape that tapers smoothly from a flat base to a point called the apex or vertex. A cone is formed by a set of line segments, half-lines, or lines connecting a common point, the apex, to all of the points on a base that is in a plane that does not contain the apex.
Slant Height of the Cone = √(r² + h²)
Surface area of the Cone = πr(r+ √(r² + h²))
Volume of the Cone = (πr2h)/3
Lateral Surface Area of a Cone = πr√(r² + h²)
Here is the source code of the program to calculate the volume and surface area of a cone.
# Python Program to Calculate the Volume and Surface Area of a Cone
# Import Module
import math
# Take the Input From the User
radius = float(input("Enter the Radius of a Cone: "))
height = float(input("Enter the Height of a Cone: "))
# Calculate Length of a Slide (Slant)
l = math.sqrt(radius * radius + height * height)
# Calculate the Surface Area
SA = math.pi * radius * (radius + l)
# Calculate the Volume
Volume = (1.0/3) * math.pi * radius * radius * height
# Calculate the Lateral Surface Area
LSA = math.pi * radius * l
# Print the Output
print("\nLength of a Side (Slant)of a Cone = %.2f" %l)
print("The Surface Area of a Cone = %.2f " %SA)
print("The Volume of a Cone = %.2f" %Volume);
print("The Lateral Surface Area of a Cone = %.2f " %LSA)
Enter the Radius of a Cone: 6
Enter the Height of a Cone: 10
Length of a Side (Slant)of a Cone = 11.66
The Surface Area of a Cone = 332.92
The Volume of a Cone = 376.99
The Lateral Surface Area of a Cone = 219.82
Comments