CS 303e - Exam 2
Fall 2009
Solutions

1. These are easy for you to check with IDLE.

2. Easy to check.

3.
f = open("myFile.txt", "r")
for line in f:
  s = line
  if s[len(s)-1] == "\n":
     s = line[:len(s)-1]
  print s, len(s)
f.close()

4.
def repeatIt(someStr, num):
  s = someStr + " "
  s *= num
  return s

5. We did this one in class.