
# ACT2-1 functions.
# Lines that start with '#' are COMMENTS.
# They are not interpreted by Python.

# Triple quotes in the first line describe the program.
# They are not interpreted by Python either.

def avg3(someList):
    '''Takes a list of three numbers and returns the average'''
    s = someList[0] + someList[1] + someList[2]
    avg = s/3.0
    return avg

def addOne(t):
    '''Takes a number and returns that number plus one'''
    y = t + 1
    return y

# Remove the '#' characters as you write the functions below.

def readShel():
    '''Read in poem.txt and returns a list of words'''
    fileName = "C:\Users\Anna\Documents\CS0931\Spring2012\Activities\ACT2-1\poem.txt"
    myFile = open(fileName,"r")
    fileString = myFile.read()
    myFile.close()
    myList = fileString.split()
    return myList

def countWordsInShel():
    '''Returns the number of words in poem.txt'''
    myList = readShel()
    count = 0
    for word in myList:
        count = count + 1
    return count 

def readMobyDick():
    '''Read in MobyDick.txt and returns a list of words'''
    fileName = "C:\Users\Anna\Documents\CS0931\Spring2012\Activities\ACT2-1\MobyDick.txt"
    myFile = open(fileName,"r")
    fileString = myFile.read()
    myFile.close()
    myList = fileString.split()
    return myList

def countWordsInMobyDick():
    '''Returns the number of words in MobyDick.txt'''
    myList = readMobyDick()
    count = 0
    for word in myList:
        count = count + 1
    return count 

