1 answer
(click or scroll down)
Review the following code. The user enters 400 for milesDriven and 0 for gallonsUsed. What will print out?
try:
milesDriven=float(input("Enter miles driven: "))
except ValueError:
print("Numbers only! Please try again.")
milesDriven=float(input("Enter miles driven: "))
try:
gallonsUsed=float(input("Enter gallons used: "))
except ValueError:
print("Numbers only! Please try again.")
gallonsUsed=float(input("Enter gallons used: "))
if(gallonsUsed==0):
print("Number can't be 0")
gallonsUsed=float(input("Enter gallons used: "))
mpg = milesDriven/gallonsUsed
print("Miles Per Gallon: ", mpg)