{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lab 07 Marked Assignment 3 Thursday Solution

# Lab 07 Marked Assignment 3 Thursday Solution - more useful...

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

Sheet1 Page 1 # William M. Farmer # 9 November 2010 # # This is a solution for Lab 07: Marked Assignment 3 on Thursday # Implements f_1 def fun1(n): return 2 ** abs(n) # Implements f_2 def fun2(n): val = 1 for i in range(n + 1): val = val * fun1(i) return val # Implements f_3 def fun3(n): list = [] for i in range(-n, n + 1): list = list + [fun1(i)] return list # Design Question # # Yes, this is a good approach. The function fun4 is more general and
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # more useful than fun2, but not any harder to write. And fun2 can be # immediately defined in terms of fun4: # # def fun2(n): # return fun4(0,n) # # Testing Question # # The input space of fun2 divide into two obvious regions: (1) negative # inputs (where the loop body is not executed) and (2) nonnegative # inputs (where the loop body is executed). The boundary points are # thus -1 and 0....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online