The actual one will be longer, but these are the types of questions likely to be on it.
def f(lst): a = i = 0 n = len(lst) while i < n: if lst[i] <= 0: i += 1 continue a += lst[i] i += 1 return a / n
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 sorted(u):
print(i, d[i])
def y(n):
if n < 10:
return str(n)
else:
d = str(n % 10)
return y(n // 10) + d
print(y(174))
def largest(lst):
x = largest(lst[1:])
if x < lst[0]:
return lst[0]
else:
return x
| You can also obtain a PDF version of this. | Version of May 31, 2014 at 3:45AM |