Python Forum
Good Morning help simplify
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Good Morning help simplify
#1
I was to create a program so I can compare the cost of fuel per vehicle I was wanting to purchase. I was able to get it to work but I think it can be simplified, maybe to clunky

# introductory statement
intro= '''
Automobile Fuel Cost Calculator

This program may help you decide which car makes sense for you
based on your budget. You will be asked to enter the MPG for the car
you have in mind, the average number of miles you expect to drive each
month and the cost per gallon for the fuel.
'''
print(intro)
# user adds miles per gallon
mpg = input("Please enter mpg (miles per gallon:")
mpg = float(mpg)
# user enters miles for the month
distance = input("Please enter the average miles driven in a month:")
distance = float(distance)
# user enters price per gallon
ppg = input("Enter fuel price per gallons:")
ppg = float(ppg)

a = distance
b = ppg
c = mpg

total1 = a/c
total2 = b*total1
print("Given that the price of fuel is at ${:.2f}/gallon and you travel around {} miles per month:".format(ppg, distance))

print("Amount of gallons in fuel used each month is: {0:.1f}".format(total1))
print("Your monthly estimated cost of fuel is: ${0:.2f}".format(total2))
Reply


Messages In This Thread
Good Morning help simplify - by raymond2688 - Jul-17-2019, 01:43 PM
RE: Good Morning help simplify - by ichabod801 - Jul-17-2019, 02:01 PM
RE: Good Morning help simplify - by raymond2688 - Jul-17-2019, 02:40 PM
RE: Good Morning help simplify - by jefsummers - Jul-22-2019, 08:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simplify a program using functions nzieno 8 10,065 Oct-06-2016, 07:29 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020