Implement p0 tutorial.

This commit is contained in:
2021-10-11 21:01:31 -04:00
parent a95016431f
commit cd948fe640
15 changed files with 165 additions and 159 deletions

View File

@@ -28,8 +28,10 @@ def shopSmart(orderList, fruitShops):
orderList: List of (fruit, numPound) tuples
fruitShops: List of FruitShops
"""
"*** YOUR CODE HERE ***"
return None
prices = [(shop.getPriceOfOrder(orderList), shop)
for shop in fruitShops]
return min(prices)[1]
if __name__ == '__main__':
"This code runs when you invoke the script from the command line"
@@ -39,6 +41,6 @@ if __name__ == '__main__':
dir2 = {'apples': 1.0, 'oranges': 5.0}
shop2 = shop.FruitShop('shop2',dir2)
shops = [shop1, shop2]
print "For orders ", orders, ", the best shop is", shopSmart(orders, shops).getName()
print("For orders ", orders, ", the best shop is", shopSmart(orders, shops).getName())
orders = [('apples',3.0)]
print "For orders: ", orders, ", the best shop is", shopSmart(orders, shops).getName()
print("For orders: ", orders, ", the best shop is", shopSmart(orders, shops).getName())