Project 0: Unix/Python Tutorial

(Thanks to John DeNero and Dan Klein.)


There are two primary objectives of this project: get a basic understanding of Python, and familiarize yourself with the grading environment of the class.

Objective 1

Checkout the files for this project based on instructions here. Edit the file email.txt and, if you wish, project0/codename.txt. Then check those changes in.

Objective 2

If you are unfamiliar with Python, check out this Python tutorial for the class.

To test your basic understanding of Python and the submission software, complete the following two problems.

Problem 1: Add a buyLotsOfFruit(orderList) function to which takes a list of (fruit,pound) tuples and returns the cost of your list. If there is some fruit in the list which doesn't appear in fruitPrices it should print an error message and return None (which is like nil in Scheme). Please do not change the fruitPrices variable.

Test Case: We will check your code by testing that the script correctly outputs

Cost of [('apples', 2.0), ('pears', 3.0), ('limes', 4.0)] is 12.25

Problem 2 (for submission): Fill in the function shopSmart(orders,shops) in, which takes an orderList (like the kind passed in to FruitShop.getPriceOfOrder) and a list of FruitShop and returns the FruitShop where your order costs the least amount in total. Don't change the file name or variable names, please. Note that we will provide the implementation as a "support" file, so you don't need to submit yours.

Test Case: We will check that, with the following variable definitions:

orders1 = [('apples',1.0), ('oranges',3.0)]
orders2 = [('apples',3.0)]			 
dir1 = {'apples': 2.0, 'oranges':1.0}
shop1 =  shop.FruitShop('shop1',dir1)
dir2 = {'apples': 1.0, 'oranges': 5.0}
shop2 = shop.FruitShop('shop2',dir2)
shops = [shop1, shop2]

The following are true:

shopSmart.shopSmart(orders1, shops).getName() == 'shop1'


shopSmart.shopSmart(orders2, shops).getName() == 'shop2'


After you have completed one or both of the problems, check to make sure they provide the proper output on the results page