Question: ( 1 ) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. ( 2 )
Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. Implement the printmenu function to print the following command menu. Implement the executemenu function that takes parameters: a character representing the user's choice and the user provided sample text. executemenu performs the menu options, according to the user's choice, by calling the appropriate functions described below.
In the main program, call printmenu and prompt for the user's choice of menu options for analyzingediting the string. Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling executemenu Then, print the menu and prompt for a new option. Continue until the user enters q Hint: Implement Quit before implementing other options. Implement the getnumofnonWScharacters function. getnumofnonWScharacters has a string parameter and returns the number of characters in the string, excluding all whitespace. Call getnumofnonWScharacters in the executemenu function, and then output the returned value. Implement the getnumofwords function. getnumofwords has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call getnumofwords in the executemenu function, and then output the returned value. Implement the fixcapitalization function. fixcapitalization has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fixcapitalization also returns the number of letters that have been capitalized. Call fixcapitalization in the executemenu function, and then output the number of letters capitalized followed by the edited string. Hint : Look up and use Python functions islower and upper to complete this task. Hint : Create an empty string and use string concatenation to make edits to the string. Implement the replacepunctuation function. replacepunctuation has a string parameter and two keyword argument parameters exclamationcount and semicoloncount. replacepunctuation updates the string by replacing each exclamation point character with a period and each semicolon ; character with a comma replacepunctuation also counts the number of times each character is replaced and outputs those counts. Lastly, replacepunctuation returns the updated string. Call replacepunctuation in the executemenu function, and then output the edited string. Implement the shortenspace function. shortenspace has a string parameter and updates the string by replacing all sequences of or more spaces with a single space. shortenspace returns the string. Call shortenspace in the executemenu function, and then output the edited string. Hint: Look up and use Python function isspace
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
