Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Open addition.py and look at the definition of add: def add ( a , b ) : Return the sum of a and b

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 to read:
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 rerun the autograder (omitting the results for questions 2 and 3):
[cs188-ta@nova ~/tutorial]$ python autograder.py -q q1
Starting on 1-21 at 23:52:05
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 q1: 1/1 ###
Finished at 23:41:01
Provisional grades
==================
Question q1: 1/1
Question q2: 0/1
Question q3: 0/1
------------------
Total: 1/3
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. You can also run the autograder with the option --mute to temporarily hide such lines, as follows:
[cs188-ta@nova ~/tutorial]$ python autograder.py -q q1--mute
Starting on 1-22 at 14:15:33
Question q1
===========
*** PASS: test_cases/q1/addition1.test
*** add(a,b) returns the sum of a and b
*** PASS: test_cases/q1/addition2.test
*** add(a,b) returns the sum of a and b
*** PASS: test_cases/q1/addition3.test
*** add(a,b) returns the sum of a and b
### Question q1: 1/1 ###

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

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

4. Label problematic uses of language and their remedies

Answered: 1 week ago