I'm so new to programming logic I'm not sure I can phrase this properly. I'm using Python 2.7 and am trying to write a script that will repeat until zero is entered. I've tried if, else, and while statements and have concluded that I don't know enough about logic to know anything about Python. For example...I'm so new that init means nothing to me. I've seen the phrase in almost every search result I've received, but I don't no what it means or is. The class I'm in is a LOGIC class not a Python class. I can write it in pseudocode but I would really like to see a working model. Please Help. This script runs through and will exit when zero is entered, but it will not prompt for miles driven again.
#Cost of Trip Ch2 Q8
print "To Calculate the cost of your trip,"
print "enter the miles driven or zero to quit"
getMiles = float(input ('Enter Miles: '))
while getMiles == 0:
print "END OF PROGRAM"
exit
fuelEcon = getMiles / 20
fuelCost = float(input ('Enter Cost of Fuel: $'))
costOfTrip = getMiles * fuelCost
fuelIncrease = (fuelCost * .1) + fuelCost
futureTrip = getMiles * fuelIncrease
while costOfTrip == float:
getMiles
print "Cost of Trip: $", costOfTrip
print "Cost of Trip With 10% Increase in Fuel Cost: $", futureTrip
Something that I forgot to mention was the mandatory "END OF PROGRAM" statement. I used a combination of your answers and this works. Again, Thank you everyone. I can stop banging my head on the wall.
#Cost of Trip Ch2 Q8
print "To Calculate the cost of your trip,"
print "enter the miles driven or enter zero to quit"
getMiles = float(raw_input ('Enter Miles: '))
while getMiles >= 0:
if getMiles == 0:
print "END OF PROGRAM"
exit()
fuelEcon = getMiles / 20
fuelCost = float(input ('Enter Cost of Fuel: $'))
costOfTrip = getMiles * fuelCost
fuelIncrease = (fuelCost * .1) + fuelCost
futureTrip = getMiles * fuelIncrease
print "Cost of Trip: $", costOfTrip
print "Cost of Trip With 10% Increase in Fuel Cost: $", futureTrip
getMiles = float(raw_input ('Enter Miles: '))