CS 6752 Homework 2
Due: Thursday, September 15 at 1:30 pm

Assignment 2: Have some Whiskey

In this HW, you will get practice reading in data files and perfomring some simple organization and analysis on them.

In t-square we will provide you with a small CSV data file about whiskeys of the world. Each row is a different whiskey and it has columns (attributes) for the whiskey name, country of origin, rating, category, price, ABV (alcohol by volume), age, and brand.

Once the data is read in, your program should present the user repeatedly with four options:

More about each option:

Lookup a whiskey by name - Your program should prompt the user to type in a whiskey name. If there is an exact match for that name in the data set, you should print out all the relevant attributes of that whiskey in some nicely formatted manner. If it isn't present, tell the user so.

Find whiskeys in a set price range - Your program should prompt the user to enter two numbers, a low and a high value. Once the user does so, your program should print out each whiskey whose price falls in that range, sorted by rating (highest to lowest). Just print out each matching whiskey's rating and name per line.

Calculate a quality formula - Your program should allow the user to enter a value equation. The equation will be some number a that is multiplied by its rating minus some number b multiplied by its costs. Your program should prompt the user to enter these two numbers. Then it should calculate each whiskey's value according to those values, and it should print out the top 10 whiskeys according to that value formula. Print the whiskey rank, name, "value", rating and price on a line.

We will place a small sample data file in t-square for you to work and test with. When we evaluate your program, we will use a much bigger data file. It will have the exact same format as the first file, however.

A sample run might look like the following:

> python whiskey.py
What is the name of your whiskey data file?
whiskey-data.csv

Choose an option:
l - Look up a whiskey by name
p - Find whiskeys in a price range
f - See top whiskeys by a "quality" formula
q - quit

? l
Enter whiskey name
Bunnahabhain 25

Islay whiskey from Scotland
*-rating, $292, 46.3-ABV, 25-age

Choose an option:
? p
Enter the low and high prices
20 30

Your whiskey choices are:
Forty Creek Barrel Select Canadian Whiskey (69) $23
Kellan Irish Whiskey (47) $20

Choose an option:
? f
Enter rating factor and price factor
4 2

The top 10 whiskeys according to that formula are:
1. Buchanan's Master Blended Scotch 276 (96 at $54)
2. ...

Choose an option:
? q
Quit
Notes & Hints:
  • You can assume that the user will only enter integers for the prices and formula factors.
  • That said, the user may make mistakes such as entering an "unallowable" integer, or may respond with an inappropriate character to the command prompt. Your program should handle these situations well.
  • Do NOT code this entire program in one big chunk. Modularize your code. Get it working in pieces.
  • (Extra credit) For those who want a true challenge, make it so that a user doesn't have to enter the long whiskey name string exactly. How might you help them? Feel free to embellish your program in any other ways, but make sure the core functionality still operates correctly.

    Turn-in Procedures

    After you have finished the above assignment, turn it in via T-Square. Please name your file LastName_whiskey.py.