Answer :
To write a program using dictionaries to store car prices and calculate the total cost with tax, you can follow these steps:
1) First, create a dictionary called "cars" to store the key-value pairs of cars and prices. Here's an example of how you can do it:
cars = {"Tesla M3": 67000, "Lexus RX400": 53000, "Infinity G12": 14000, "Ford F150": 60000, "Honda Civic": 31500}
2) Next, use the input method to ask the user which car they want to buy. For example, you can prompt the user with the following message:
car_choice = input("Which car do you want to buy? ")
3) After the user enters their choice, you need to locate the car in the "cars" dictionary object. You can use the get() method to retrieve the price associated with the car choice. Here's an example of how you can do it:
car_price = cars.get(car_choice)
4) Finally, calculate the total cost with tax. Assuming the tax rate is 7%, you can use the following formula:
total_cost = car_price + (car_price * 0.07)
You can then display the result to the user in the desired format. For example:
print("The car you selected", car_choice, "is for $", car_price, "and with tax the total cost will be $", total_cost)
To solve this problem, you need to create a dictionary called "cars" to store the key-value pairs of car names and prices. You can use the car names as keys and the prices as values. Then, you prompt the user to enter the car they want to buy using the input method and store their choice in a variable called "car_choice". Next, you use the get() method to retrieve the price associated with the user's car choice from the "cars" dictionary and store it in a variable called "car_price". Finally, you calculate the total cost by adding the tax to the car price and display the result to the user.
Note: It's important to handle cases where the user enters a car name that is not in the dictionary. You can use if statements or try-except blocks to handle such cases and provide appropriate feedback to the user.
To know more about program visit :-
https://brainly.com/question/30613605
#SPJ11