Question: You are creating a program using Python that opens and reads a file. Your program opens a file that is named .txt. Your program will

You are creating a program using Python that opens and reads a file. Your program opens a file that is named .txt. Your program will display a menu that allows a user to choose how to process the file.

Write a program that:

  • Opens a file.
  • Prompts a user with a menu of choices.
  • User makes a choice.
    • If one is chosen - the program counts the number of words in the novel.
    • If two is chosen - the program prompts for a word to search for. It returns the number of instances of that word.
    • if three is chosen - the program returns a secret message that is embedded in the file delimited by @s.
    • if four is chosen, close the output file and program exits.
  • The menu will continue to display as long as four is not entered.
  • Define a function called display_menu()
    • displays a menu
    • returns the option chosen.
  • Define a function called get_word_count()
    • resets handle_input
    • reads every record in the file
    • counts every word in the record
    • adds count to a total count
    • returns the total count
  • Define a function called get_specific_count()
    • resets handle_input
    • reads every record in the file
    • looks to match the word and counts the matches
  • Define a function called find_message()
    • resets handle_input
    • finds a message embedded between 2 @s

You are creating a program using Python that

Run the Program @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 1 Total Word Count @ 2 Specific Word Count @ 3 Find The Message @ 4 Exit @@@@@@@@@@@@@@@@@@@@@@@@@@@@ Enter your selection > @@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 Total Word Count @ 2 Specific Word Count @ 3 Find The Message @ 4 Exit @@@@@@@@@@@@@@@@@@@@@@@@@@@@ Enter your selection > 1 @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 1 Total Word Count @ 2 Specific Word Count @ 3 Find The Message @ 4 Exit @@@@@@@@@@@@@@@@@@@@@@@@@@@@ Enter your selection > 1 Total:217111 @

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 General Management Questions!