Python program to Calculate Mass, Density and Volume

result = 0
mdv = input("Choose one to calculate(m,d,v) : ")
if mdv == 'm':
 d = float(input("Density: "))
 v = float(input("Volume: "))
 result = ("Mass is : " + str(d*v))
elif mdv == 'd':
 m = float(input("Mass: "))
 v = float(input("Volume: "))
 result = ("Density is : " + str(m/v))
elif mdv == 'v':
 m = float(input("Mass: "))
 d = float(input("Density: "))
 result = ("Volume is : " + str(m/d))
print(result)

 

Output:

Choose one to calculate(m,d,v) : m
Density: 10
Volume: 12
Mass is : 120.0

 

Choose one to calculate(m,d,v) : d
Mass: 200
Volume: 12
Density is : 16.666666666666668

 

Subscribe For Daily Updates