Write a python program that will open a file and place each line of text from the file into a Python list. This program will calculate total number of lines, words and characters in the file. Write a python function counter to calculate and return total number of lines, words and characters in a text (.txt) file. The count function needs to return total number of lines, words and characters from the function. Also the function will take two parameters: • fileName is the name of the file that need to be opened to calculate the file stats (# of lines, # of words and # of characters). • lineList – this is python l
Write a python program that will open a file and place each line of text from the file into a
Python list. This program will calculate total number of lines, words and characters in the file. Write a python function counter to calculate and return total number of lines, words and characters in a text (.txt) file. The count function needs to return total number of lines, words and characters from the function.
Also the function will take two parameters:
• fileName is the name of the file that need to be opened to calculate the file stats (# of lines, # of words and # of characters).
• lineList – this is python list that contains that will add each line (strip of new line feed in the line) to the python list.
#function count will open the file fileName and counts how many lines, words and chars
# in the file, and place each line of the file in the lineList parameter.
# The function must RETURN numOfLine, numOfWords, numOfChars as return value,
# and lineList as parameter
#
# numOfLine: number of lines in the file
# numOfWords: number of lines in the file
# numOfChars: number of lines in the file
#@parm: fileName - this is the filename to be opened
#@parm: lineList - this list contains all the text in each of lines
# from the file. Each line of text is added to the list.
# Need to remove the new line feed '\n' from the line
# before adding to the list.
#@return numOfLine, numOfWords, numOfChars
def count(fileName, lineList):
After calling count function which will return 3 values and stored all the lines in the lineList parameter.
Your program needs to print out all lines stored in lineList list (MUST print out the lineList outside the count function), you MUST print out the return value of total number of lines, words, and characters. These values are returned from count function.
In addition, you need to print out number of uppercase letters, lowercase letters, spaces, digits, sentences. Assuming each sentences ends with a period ’.’, exclamation mark (!) or questions mark ‘?’.
All the printout MUST be outside the count function. That is, you can NOT print them within the count function.
An example text file has been given along with the end result when used with the python program. The program created should have an out put that matches the example given.



Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images









