Assignment 6
Due date: 3/8/10
Average number of words in a sentence
Write a function called avg_words_per_sentence(file_name) that returns the average number of words per sentence in the given file, which is assumed to contain English text.
Call your program words_per_sentence.py. It should be runnable as a script as: python words_persentence.py file_name. To access command-line arguments use sys.argv as discussed in the lab. If the given file name does not exist, print a message and exit (you can use sys.exit() in your program to do so). Your program should print a message with the result of running avg_words_per_sentence:
The average number of lines per sentence in the file xxx is yyy.
Structuring your program
Your program should be structured as follows:
# all the function definitions go here
if __name__ == '__main__' :
# code for handling the file_name
average = avg_words_per_sentence(file_name)
# display the result
Include an identifying comment as usual, plus comments that explain how your code works.
