Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python coding: 1. (25 points total) Given a set of car inventory information read from a file and converted to a list, write a

using python coding: image text in transcribed
1. (25 points total) Given a set of car inventory information read from a file and converted to a list, write a Python function to accept the car list as input and return a "reverse" dictionary. A partial list of car information is given below: carList = [["Honda", "Accord", 2014, 62000], ["Toyota", "Camry", 2015, 43500], ["Ford", "Focus", 2013, 58000], ["Honda", "Civic", 2012, 71000]. ] The data is a list of lists and includes the manufacturer of the car (e.g. "Honda"), the model, year, and mileage. To facilitate looking up cars in the inventory, the reverse dictionary should be built from the list by reading each sub-list (e.g. ["Honda", "Accord", 2014, 62000]) and use the manufacturer ("Honda") as the dictionary key. The other elements in the list ("Accord", 2014, and 62000) are the values for the particular key. Recall that you have two cases your code needs to handle: (1) the key is not already in the dictionary, and (2) the key is already there. The logic and code are very similar to that used to build the dictionary for A1. To get you started I've supplied the first lines and return statement. You only need to provide the code in the middle. def buildDict (carList): Dict = {} # Name of the dictionary to be built - initially empty %3D # insert code below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions