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 4

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

21.
1/(1 – (–1/2)) =  1/(3/2) = 2/3

22.
9 + 99 + ... + 9<--[30 9s]-->9 =
10 + 100 + ... +  10<--[30 0s]-->0 - 30 =
1<--[30 1s]-->10 - 30 = 
1<--[28 1s]-->1080
23.
def randString01(n): '''Returns a randon string of 0s and 1s of length n''' s = '' for count in range(n): s += str(randint(0,1)) return s
24.
days = 0 percentSaw = 0 while percentSaw < 90: percentSaw += 0.15*(100 - percentSaw) days += 1 print(days)
25.
def addPowersOfX(x, n): p = 1 sumP = 0 while n >= 0: sumP += p p *= x n -= 1 return sumP x = 100 print(addPowersOfX(x, 10) * addPowersOfX(x*x, 5))
26.
def areaUnderParabola(a, b, n): h = (b-a)/n s = 0.0 i = 0; while i < n: x = a + i*h + h/2 s += x*x*h i += 1 return s




Copyright © 2010 by Skylight Publishing