Question: 2.py file : numbers = [[4, 3], [1,2], [154,233], [555,-444]] def show_add_pair(pair): print str(pair[0]) + '+' + str(pair[1]) + '= ' + str(pair[0] + pair[1])

2.py file:

numbers = [[4, 3], [1,2], [154,233], [555,-444]]

def show_add_pair(pair):

print str(pair[0]) + '+' + str(pair[1]) + '= ' + str(pair[0] + pair[1])

print ' Part 1'

print '4+3=',4+3

print '1+2=',1+2

print '154+233=',154+233

print '555+-444=',555+(-444)

print ' Part 2'

show_add_pair(numbers[0])

show_add_pair(numbers[1])

show_add_pair(numbers[2])

show_add_pair(numbers[3])

print ' Part 3'

for n in numbers:

show_add_pair(n)

print ' Part 4'

map(show_add_pair, numbers)

2: Review and execute 2.py file and its 4 parts. Contrast the design of each of the 4 parts. Are some of the designs better than the others? If so, why? If not, why not?

3. Review and execute the Assignment2.py file and its 4 parts. Write down requirements that could have led to each of the 4 parts (you can use any specification type you like: natural language, structured, etc.) Requirements that require a specific design, solution, or implementation are overly constrained and should be avoided. Explain why the requirements are similar or different between the 4 parts.

4. Explain how (or if) the Iterator pattern applies to 2.py file

5. Modify Assignment2.py, such that the line 0+1= 1 is added on each of the parts (i.e., 4 times). Explain, in each case, the relative difficulty of adding this output to the code. Also, turn in your updated 2.py file.

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!