Solutions to other tests:
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  

Mathematics for the Digital Age
and
Programming in Python


>>> Second Edition

Test 9

1.
(a) T   (b) T   (c) F
2.
(a) T   (b) T   (c) T
3.
B
4.
(a) F   (b) T   (c) F   (d) T
5.
B
6.
A
7.
C
8.
(a), (b), (c), (d)
9.
(a) F   (b) T   (c) T   (d) T
10.
(a) T   (b) F   (c) T   (d) T
11.
(b), (c), (d)
12.
(b), (c)
13.
C
14.
D
15.
B
16.
A
17.
(a) F   (b) T   (c) T  
(d) T  (e) F
18.
(a), (b), (e)
19.
(a) F   (b) F   (c) T  
20.
D

21.
def makeEmail(name1, name2, url): name2 = name2.replace(" ", "") name2 = name2.replace("'", "") dot = url.find("www.") + 4 return name1[0].lower() + name2.lower() + '@' + url[dot:]
22.
def process(expr): dot = expr.rfind('.') paren = expr.find('(', dot) return expr[dot+1:paren+1] + expr[:dot] + ", " + expr[paren+1:]
23.
r = [s.upper() for s in lst if s.isalpha()]
24.
def swapPairs(lst): i = 0 while i < len(lst) - 1: temp = lst[i] lst[i] = lst[i+1] lst[i+1] = temp i += 2
25.
def remove_duplicates(lst): i = 1 while i < len(lst): if lst[i] == lst[i-1]: del lst[i] else: i += 1
26.
f = open("Homework.txt") fOut = open("HomeworkSolutions.txt", "w") for line in f: line = line.strip() + " = " + str(eval(line)) + "\n" fOut.write(line) fOut.close() f.close()



Copyright © 2010 by Skylight Publishing