#import math from math import ceil, sqrt def stringCount(fname, target): '''return the number of times target appears in fname''' infile = open(fname, 'r') #s = infile.read() lst = infile.readlines() infile.close() #return s.count(target) count = 0 for line in lst: count += line.count(target) return count def numChars(fname): 'return the number of characters in fname' infile = open(fname, 'r') #contents = infile.read() lst = infile.readlines() infile.close() #return(len(contents)) count = 0 for line in lst: count += len(line) return count def numLines(fname): 'return the number of lines in fname' infile = open(fname, 'r') lst = infile.readlines() #print(lst) infile.close() return len(lst) def top(n): 'return the ceiling of the sqrt of n' #return math.ceil(math.sqrt(n)) return ceil(sqrt(n))