Python Density of Cylinder Program

By | May 22, 2022

Python Density of Cylinder Program

Write a program to input mass and volume of a cylinder and find the density of this cylinder using the formula d = m / v:

Formulae of Density of Cylinder

We will use the following formula for the calculation of density of the cylinder.
Density = Mass / Volume

Python Density of Cyllinder Formula Program

Code of  Python Density of Cylinder Program

'''
Python Program to calculate Density of Cylinder
using formulae: Density = Mass / Volume
'''
print("Enter Mass of the Cylinder:")
mass = float(input("Enter the Mass of the Cylinder:")) ;
volume = float(input("Enter the Volume of the Cylinder:")) ;
density = mass / volume
density = round(density,4)
print("Density of cylinder =", density)

Output

Enter Mass of the Cylinder:
Enter the Mass of the Cylinder:456
Enter the Volume of the Cylinder:200
Density of cylinder = 2.28

How this program works

First of all, the program shows a message to enter the mass of a cylinder. Similarly, a second prompt will ask for entering the volume of this cylinder.

Then program will use the formula:

density = mass / volume

The result that is density of cylinder will be displayed on the scree.

Python Program Density of Cylinder

More easy Python Programs

Here is a list of Python programs. These programs are easy to understand for beginners. The reading of programming tutorials helps building the program logic.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *