Miles Per Gallon Python Program

Code for calculating Miles Per Gallon with Python Program

# taking input from user for miles
miles = input("Enter miles driven: ")

# converting to float
miles = float(miles)

# taking input from user for gallon
gallon = input("Enter gallon used: ")

# converting to float
gallon = float(gallon)

# calculating miles per gallon in python
miles_per_gallon = miles / gallon

# printing miles_per_gallon
print("Miles per gallon: ", miles_per_gallon)

Output:

Miles Per Gallon Python Program
Miles Per Gallon Python Program

So, this is a simple Miles Per Gallon Python Program to calculate how many miles you drive in 1 gallon of oil.

What is a gallon?

A gallon is a unit of volume in imperial units and the United States customary units. Three different versions are in current use. Click here to know more about a gallon.

We hope this article will help you.

Thank you for visiting our website.


Also Read:

Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you