Python ProgrammingPython Programming

Calculate amount of energy needed to heat a volume of water, and the cost for same

Write a program in python that reads the mass of water, the temperature change from the user and electricity price per unit. Then, program should display the total amount of energy required and total cost for same. Electricity is normally billed using units of kilowatt hours rather than Joules.
##
#Python's program to calculate amount of energy needed to heat a volume of water, and the cost for same.
##

#Define the constants
HEAT_CAPACITY = 4.186
J_TO_KWH = 2.777e-7 #Python allows to write number in scientific notation

#Read the input from user
volume	 = float(input("Enter amount of water in milliliters: "))
temp	 = float(input("Enter amount of temperature increase (degrees Celsius): "))
price	 =  float(input("Enter electricity cost per unit: "))

#Calculate the energy in Joules
energy	= volume * temp * HEAT_CAPACITY
kwh		= energy * J_TO_KWH
cost	= kwh * price 

#Display the result
print("Amount of energy needed ",round(energy,2),"Joules, which will cost", round(cost,2))
Sample output of above program.
C:\Python\programs>python program6.py
Enter amount of water in milliliters: 2500
Enter amount of temperature increase (degrees Celsius): 75
Enter electricity cost per unit: 7.9
Amount of energy needed 784875.0 Joules, which will cost 1.72

C:\Python\programs>