Question: ZYBOOOKS CODE ( 1 ) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (
ZYBOOOKS CODE
Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. pt
Ex:
Enter a sample text:
we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
Implement the printmenu function to print the following command menu. pt
Ex:
MENU
c Number of nonwhitespace characters
w Number of words
f Fix capitalization
r Replace punctuation
s Shorten spaces
q Quit
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. pt
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. pt
Ex:
MENU
c Number of nonwhitespace characters
w Number of words
f Fix capitalization
r Replace punctuation
s Shorten spaces
q Quit
Choose an option:
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. pts
Ex:
Enter a sample text:
we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
MENU
c Number of nonwhitespace characters
w Number of words
f Fix capitalization
r Replace punctuation
s Shorten spaces
q Quit
Choose an option:
c
Number of nonwhitespace characters:
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. pts
Ex:
Number of words:
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. pts
Ex:
Number of letters capitalized:
Edited text: We'll continue our quest in space. There will be more shuttle flights
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
