fork download
  1. def main():
  2. gas = int(input("How many gallons of gas does your tank hold: ")) #Collects how much gas
  3. mpg = int(input("What is your fuel efficiency in miles per gallon: ")) #collects the miles per gallon
  4. miles = int(input("How many miles is your trip: ")) #Collects how long trip is
  5.  
  6. #if statements to have boundaries for the input numbers
  7. if gas >= 100: #Gas must be less 100 gallons in a tank
  8. print("\nSorry that is too much gas for a tank hold.")
  9. print("Try again!\n")
  10. main()
  11. if mpg >= 100: #car cannot be that efficient
  12. print("\nLucky, your car is way to efficient to even exist.")
  13. print("Try again!\n")
  14. main()
  15. if miles >= 5000: #the trip cannot be that long
  16. print("\nThere is no way you are driving over 5000 miles.")
  17. print("Try again!\n")
  18. main()
  19.  
  20. eff = gas*mpg #calculates the total efficient
  21.  
  22. if eff > miles: #if statement to calculate 0
  23. print("\nYou will not have to refuel.") #Print statement for zero refuels
  24. else:
  25. refuel = miles//eff #callculates how many times you have to refill
  26. print("\nYou will have to refuel",refuel,"time(s).") #Prints how many times you have to refuel
  27. main()
Runtime error #stdin #stdout 0.02s 5872KB
stdin
Standard input is empty
stdout
How many gallons of gas does your tank hold: