Develop a Python application that incorporates using appropriate data types and provides program output in a logical manner. Your program should prompt a user to enter a car brand, model, year, starting odometer reading, an ending odometer reading, and the estimated miles per gallon consumed by the vehicle. Store your data in a dictionary and print out the contents of the dictionary.

Respuesta :

Answer:

#program in Python.

# create a dictionary

car_dic = dict()

# read brand of car

car_dic['brand'] = input("Enter brand : ")

#read model of cal

car_dic['model'] = input("Enter model : ")

#read manufactured year

car_dic['year'] = int(input("Enter manufactured year : "))

#starting odometer

car_dic['start_odometer'] = int(input("Enter the starting odometer reading: "))

#ending odometer

car_dic['end_odometer'] = int(input("Enter the ending odometer reading: "))

#mileage of the car

car_dic['mileage'] = float(input("Enter miles per gallon consumed by the vehicle: "))

#Details of the car

print("Details of the car: ")

for i in car_dic:

   print(i, ": ",car_dic[i])

Explanation:

Create a dictionary "car_dic" to store the Details of the car.Then ask user to enter the details of car such as brand, model, year, start_odometer, end_odometer and mileage.Then print all the details of the car.

Output:

Enter brand : Audi

Enter model : A6

Enter manufactured year : 2019

Enter the starting odometer reading: 100

Enter the ending odometer reading: 200

Enter miles per gallon consumed by the vehicle: 12

Details of the car:

mileage :  12.0

end_odometer :  200

year :  2019

model :  A6

start_odometer :  100

brand :  Audi