Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Dictionary exercise Purpose: Use User Defined Types and use Dictionary instead of list Create a User Defined Type to manage this data, (data excerpt):

Python Dictionary exercise

Purpose: Use User Defined Types and use Dictionary instead of list

Create a User Defined Type to manage this data, (data excerpt):

Shampoo,7.35 Roast beef,20.67 Shrimp,17.92 Egg Nog,11.82 Popsicles,3.77 This excerpt is from the data file UPRODUCTS.csvimage text in transcribed.

Specification:

* Read the data file, and for each product in the data file, sort it in an alphabetic list, based on the first letter of the product. For example, store "Shampoo,7.35" in the 'S' list.

* After reading in the entire data file, sort each alphabetic list.

* After sorting each list, place each list in a Master List, starting with list [A] and ending in list [Z].

* Write a searching algorithm to search for an item in the Master List. For example, find "Shampoo" in the Master List [S] position.

Notes:

1. There are duplicates in the data file, but have different prices. For example, Salmon,16.39,Salmon.14.72. Your program doesn't need to handle the duplicates, but you can if you want.

2. One student suggested that putting all the data into one big list, and then doing a Binary Search to find the data would be a more efficient algorithm, which is true. However, this exercise is intended to teach handling lists rather than sorting techniques. Insidently, a BinarySearch would take about 8 searches to find "Shampoo", where the searching method, outlined in this assignment, would take about 16 searches.

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_2

Step: 3

blur-text-image_3

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 Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

Question Can I collect benefits if I become disabled?

Answered: 1 week ago