1. templates 2. python; x.pyc 3. def hist(x): counts = {} for i in x: try: counts[i] += 1 except: counts[i] = 1 return counts print hist([5,2,1,12,2,12]) # {1: 1, 2: 2, 12: 2, 5: 1} 4. class textfile: ntfiles = {} ## added def __init__(self,fname): self.name = fname # name textfile.ntfiles[fname] = self ## added self.fh = open(fname) # handle for the file a = textfile('x') b = textfile('y') print 'textfile names are', textfile.ntfiles.keys() ## added # ['y', 'x'] print "the number of text files open is", len(textfile.ntfiles) ## added; 2