Question: Please edit the python file to satisfied the 3 questions: Question 1 : Addition Open addition.py and look at the definition of add: def add

Please edit the python file to satisfied the 3 questions:
Question 1: Addition
Open
addition.py and look at the definition of add:
def add(a,b) :
"Return the sum of a and b
"*** YOUR CODE HERE ***"
return 0
The tests called this with a and b set to different values, but the code always returned zero. Modify this definition using the following code:
def add(a,b) :
"Return the sum of a and b
print("Passed a=%s and b=%s, returning a+b=%s%(a,b,a+b))
return a+b
Now re-run the autograder for only the question q1.
python
autograder.py -qq1
Question q1
Passed a=1 and b=1, returning a+b=2
PASS: test_cases/q1/addition1.test
add (a,b) returns the sum of a and b
Passed a=2 and b=3, returning a+b=5
*** PASS: test_cases/q1/addition2.test
***,add(a,b) returns the sum of a and b
Passed a=10 and b=-2.1, returning a+b=7.9
PASS: test_cases/q1/addition3.test
***,add(a,b) returns the sum of a and b
### Question q3: 1/1 ###
Finished at 22:54:31
Provisional grades
Question q3: 1/1
Total: 11
You now pass all tests, getting full marks for question 1. Notice the new lines "Passed a=..." which appear before "*** PASS: ...". These are produced by the print statement in add. You can use print statements like that to output information useful for debugging.
Question 2: buyLotsOfFruit function
Add a buyLotsOfFruit(orderList) function to
buyLotsOfFruit.py 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. Please do not change the fruitPrices variable.
Total: 11
You now pass all tests, getting full marks for question 1. Notice the new lines "Passed a=..." which appear before "*** PASS: ...". These are produced by the print statement in add. You can use print statements like that to output information useful for debugging.
Question 2: buyLotsOfFruit function
Add a buyLotsOfFruit(orderList) function to
buyLotsOfFruit.py 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. Please do not change the fruitPrices variable.
Run python
autograder.py until question 2 passes all tests and you get full marks. Each test will confirm that buyLotsOfFruit(orderList) returns the correct answer given various possible inputs. For example, test_cases/q2/food_price1.test tests whether:
Cost of [('apples',2.0),('pears',3.0),('limes',4.0)] is 12.25
Question 3: shopSmart function
Fill in the function shopSmart(orders,shops) in
shopSmart.py, 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
shop.py implementation as a "support" file, so you don't need to submit yours.
Run python
autograder.py until question 3 passes all tests and you get full marks. Each test will confirm that shopSmart(orders,shops) returns the correct answer given various possible inputs. For example, with the following variable definitions:
orders 'apples', 1.0),('oranges',3.0)
 Please edit the python file to satisfied the 3 questions: Question

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!