fastread homefastrread library fastread menu

Python : calculates miles-per-gallon

Tutorial by:Rizwan Abdullah      Date: 2016-06-16 02:26:01

❰ Previous Next ❱


 
# Calculate Miles Per Gallon
print("This program calculates mpg.")
 
# Get miles driven from the user
miles_driven = input("Enter miles driven:")
# Convert text entered to a
# floating point number
miles_driven = float(miles_driven)
 
# Get gallons used from the user
gallons_used = input("Enter gallons used:")
# Convert text entered to a
# floating point number
gallons_used = float(gallons_used)
 
# Calculate and print the answer
mpg = miles_driven / gallons_used
print("Miles per gallon:", mpg)

❰ Previous Next ❱


Python

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website