This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Test 2: Compsci 06 Owen Astrachan Robert Duvall November 17/18, 2010 Name: NetID/Login: Honor code acknowledgment (signature) value grade Problem 1 12 pts. Problem 2 6 pts. Problem 3 12 pts. Problem 4 8 pts. Problem 5 20 pts. Problem 6 10 pts. TOTAL: 68 pts. This test has 10 pages, be sure your test has them all. Do NOT spend too much time on one question remember that this class lasts 75 minutes. The last page is blank, if you use it make a note for the problem. In writing code you do not need to worry about specifying the proper import statements . Dont worry about getting function or method names exactly right. Assume that all libraries and packages weve discussed are imported in any code you write. 1 PROBLEM 1 : ( Exlax (12 points) ) Part A (4 points) Complete the list comprehension below to create a list from all the strings in the list compounds , a list of strings, that have fewer than six characters. [ for w in compounds ] Part B (4 points) Write a list comprehension that creates a list of all the multiples of 5 greater than 0 and less than 4096, e.g., [5,10,15,...,4095]. Part C (4 points) Write a list comprehension that creates a list of all the prime numbers less than 10,000. You can use the function prime below that returns True if and only if its parameter num is a prime number. def prime(num): if num == 2: return True if num % 2 == 0: return False limit = int(math.sqrt(num)) + 1 for n in range(3,limit): if num % n == 0: return False return True 2 PROBLEM 2 : ( Whats the Point? (6 points) ) Write the function minDistance that returns the minimal distance between two points in a list of points where points are represented as tuples....
View Full
Document
 Fall '09

Click to edit the document details