Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a function shopSmart(orders, shops), which takes an orderList ( List of (fruit, numPounds) tuples ) and a list of FruitShop and returns the FruitShop

write a function shopSmart(orders, shops), which takes an orderList ( List of (fruit, numPounds) tuples ) and a list of FruitShop and returns the FruitShop where your order costs the least amount in total.

""" Test your function to have the following output when running this cell Welcome to shop1 fruit shop Welcome to shop2 fruit shop For orders: [('apples', 1.0), ('oranges', 3.0)] best shop is shop1 For orders: [('apples', 3.0)] best shop is shop2 """ def shopSmart(orderList, fruitShops): """  orderList: List of (fruit, numPound) tuples  fruitShops: List of FruitShops  """ "*** YOUR CODE HERE ***" orders = [('apples',1.0), ('oranges',3.0)] dir1 = {'apples': 2.0, 'oranges':1.0} shop1 = FruitShop('shop1',dir1) dir2 = {'apples': 1.0, 'oranges': 5.0} shop2 = FruitShop('shop2',dir2) shops = [shop1, shop2] 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()) 

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

Students also viewed these Databases questions