Part of the series

Several example codes

~1 min read • Updated Sep 16, 2025

Program Overview

This Python program calculates both the volume and the lateral surface area of a cylinder.

Python Code:


import math

radius = float(input("Please enter the radius of the cylinder: "))
height = float(input("Please enter the height of the cylinder: "))

volume = math.pi * radius ** 2 * height
surface_area = 2 * math.pi * radius * height

print("Volume of the cylinder is:", volume)
print("Lateral surface area of the cylinder is:", surface_area)

Sample Output:


Please enter the radius of the cylinder: 3
Please enter the height of the cylinder: 5
Volume of the cylinder is: 141.3716694115407
Lateral surface area of the cylinder is: 94.24777960769379

Explanation:

Here's how the program works:
- It uses the math module to access the constant pi.
- The volume is calculated using the formula π × r² × h.
- The lateral surface area is calculated using 2 × π × r × h.
- The results are printed using the print() function.


Written & researched by Dr. Shahin Siami