These are sample questions that are very similar to the ones I will ask on the midterm. The actual midterm will be about this length.
i = 1
while i < 10:
print i * "x"
i += 3
def x(s, c):
i = 0
while i < len(s):
if s[i] == c:
return i
i += 1
return -1
def a(s):
if len(s) < 2:
return s
return s[ -1] + a(s [1: -1]) + s[0]
d = dict ()
while True:
try:
line = input ("EOF to stop > ")
except EOFError:
break
for i in line:
d[i] = d.get(i, 0) + 1
u = d.keys()
for i in u:
print(i, d[i])
ECS 10, Basic Concepts of Computing Winter Quarter 2012 |