## ITgirl2010

i have been working on this code

``````'''Calculate the cost of fuel for a road trip'''

def main():
distance = float(raw_input("Enter distance in kilometres: "))
litresPer100K = float(raw_input("Enter economy (ltr/100km): "))
pricePerLitre = float(raw_input("Enter fuel price per litre (\$): "))

cost = distance / 100 * litresPer100K * pricePerLitre

print "Fuel cost is \$%0.2f" % cost

main()``````

now this works but i need to include how to calculate the cost of fuel for each trip.

i am unsure how to approach this

any suggestion or help would be great

.... dont no how much longer i can look at this :(

## vegaseat 1,720

Do you want to do several road trips and keep petrol price and economy the same?

## ITgirl2010

I need to calculate the fuel cost for a whole trip with keeping the three parameters (distance, econome and the price of fuel ) changeable

## pyTony 888

I need to calculate the fuel cost for a whole trip with keeping the three parameters (distance, econome and the price of fuel ) changeable

Maybe use parameters in the function like this (pseudo code)

``````def roadtrip(what1,what2 etc):
#no inputs, no prints
#do my calculation
return result_of_my_calculation

total=0.0
#repeat
#  raw inputs from your function
print "Fuel cost is \$%0.2f" % cost
#add to total and print it also
#and finish when user wants to``````

## ultimatebuster 14

I don't understand what you are doing wrong?

Are you looking for a function?

``````def calculatefuel(distance, economy, price):
return distance / 100 * economy * price``````

## ITgirl2010

from the code that ive written above i need to calculate the the cost of fuel for a trip
after a user has entered in the cost of fuel , economy of the car and the length of the trip