Question: PLS Help with code! Write a program named labprep8.py that prompts the user for a filename to evaluate, reads the contents of the file and

PLS Help with code! Write a program named labprep8.py that prompts the user for a filename to evaluate, reads the contents of the file and displays an alphabetical analysis of the number of occurrences of each character contained in the file. Youre provided with several files that you can use to test your Python program. It should work correctly with all of them.

Part 1

#Define a main() function that displays a message describing the purpose of the program

#Prompt the user for the file name containing the text to be processed

PART 2 The readData() function should accept one argument (a filename as a String) and should return two values (a String and a Set). The String returned contains the contents of the text file. The Set returned contains all the characters in the text file with no duplicates.

#Define the readData() function to accept one argument, a String

#Open the text file using the file name String provided as an argument

#Read the contents of the text file into a new String #Close the text file

#Create a Set containing all the unique characters in the String read from the text file

# Return the the text from the file as a String and the Set of unique characters.

Part 3 The calc() function should accept two arguments (a String and a Set) and returns a Dictionary. The String and Set arguments were created by the readData() function and contain the data from the text file and the Set of unique characters. The calc() function creates and returns a Dictionary containing the number of occurrences of each character in the Set

#Define the calc() function that accepts two arguments, a String and a Set

#Create a Dictionary using the entries in the Set as keys and the number of occurrences for each entry in the String as values

#The calc() function should return the new Dictionary

Part 4 Modify the main() function

#Modify the main() function to display the message, 'Reading data file...'

#Modify the main() function to call readData() providing the file name as an argument. (Remember to assign the String and Set returned by readData() to variables)

#Modify the main() function to display the message, 'Analyzing data file...'

#Modify the main() function to call calc() providing the String and Set as arguments (Remember to assign the Dictionary returned by calc() to a variable)

#Modify the main() function to display the message, 'Printing analysis results...'

#Print the key - value pairs from the Dictionary in alphabetical order

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!