Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'{your_value1:.2f} {your_value2:.2f} {your_value3:.2f}')

Ex: If the input is:

20.0
3.1599
Then the output is:

3.16 11.85 79.00

Respuesta :

The program is an illustration of a sequential program.

What are sequential programs?

Sequential programs are programs that do not require loops and conditional statements

The actual program

The program in Python, where comments are used to explain each line is as follows:

#This gets the input for the car's miles/gallon

carMilesGallon = float(input("Car's miles/gallon: "))

#This gets the input for the gas dollars/gallon

gasDollarsGallon = float(input("Gas dollars/gallon: "))

#This calculates the cost for 20 miles

cost20 = (gasDollarsGallon/carMilesGallon) * 20.0

#This calculates the cost for 75 miles

cost75 = (gasDollarsGallon/carMilesGallon) * 75.0

#This calculates the cost for 500 miles

cost500 = (gasDollarsGallon/carMilesGallon) * 500.0

#This prints the calculated costs

print(f'{cost20:.2f} {cost75:.2f} {cost500:.2f}')

Read more about sequential programs at:

https://brainly.com/question/17970226

Otras preguntas