Lab 07 Marked Assignment 3 Tuesday Solution

Lab 07 Marked Assignment 3 Tuesday Solution - # # No...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 # William M. Farmer # 9 November 2010 # # This is a solution for Lab 07: Marked Assignment 3 on Tuesday # Implements f_1 def fun1(n): return (n + 1) ** 3 # Implements f_2 def fun2(m,n): val = 0 for i in range(m, n + 1): val = val + fun1(i ** 2) return val # Implements f_3 def fun3(n): list = [] for i in range(1, n + 2): list = list + [fun1(i)] return list # Design Question
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # # No changes would have to be made to fun3 as long as the modified fun1 # still took exactly one input. # # Testing Question # # Only one test case is needed because, when n is negative, # # range(1, n + 2) # # is and so the body of the for loop is never executed. That is, # fun3 behaves exactly the same for all negative inputs....
View Full Document

Ask a homework question - tutors are online