*******************In Pythonplease*******************
(1) Prompt the user to enter a string of theirchoosing. Store the text in a string. Output the string. (1 pt)
Enter a sample text:
we'll continue our quest in space. there will be more shuttleflights and more shuttle crews and, yes; more volunteers, morecivilians, more teachers in space. nothing ends here; our hopes andour journeys continue!
You entered: we'll continue our quest in space. there will bemore shuttle flights and more shuttle crews and, yes; morevolunteers, more civilians, more teachers in space. nothing endshere; our hopes and our journeys continue!
(2) Implement a print_menu() function, whichhas a string as a parameter, outputs a menu of user options foranalyzing/editing the string, and returns the user's entered menuoption and the sample text string (which can be edited inside theprint_menu() function). Each option is represented by a singlecharacter.
If an invalid character is entered, continue to prompt for avalid choice. Hint: Implement the Quit menu option beforeimplementing other options. Call print_menu() in the main sectionof your code. Continue to call print_menu() until the user enters qto Quit. (3 pts)
Ex:Â Â
MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit
Choose an option:
(3) Implement theget_num_of_non_WS_characters() function.get_num_of_non_WS_characters() has a string parameter and returnsthe number of characters in the string, excluding all whitespace.Call get_num_of_non_WS_characters() in the print_menu() function.(4 pts)
Ex:
Number of non-whitespace characters: 181
(4) Implement the get_num_of_words() function.get_num_of_words() has a string parameter and returns the number ofwords in the string. Hint: Words end when a space is reached exceptfor the last word in a sentence. Call get_num_of_words() in theprint_menu() function. (3 pts)
Ex:
Number of words: 35
(5) Implement the fix_capitalization()function. fix_capitalization() has a string parameter and returnsan updated string, where lowercase letters at the beginning ofsentences are replaced with uppercase letters. fix_capitalization()also returns the number of letters that have been capitalized. Callfix_capitalization() in the print_menu() function, and then outputthe the edited string followed by the number of letterscapitalized. Hint 1: Look up and use Python functions .islower()and .upper() to complete this task. Hint 2: Create an empty stringand use string concatenation to make edits to the string. (3pts)
Ex:
Number of letters capitalized: 3
Edited text: We'll continue our quest in space. There will be moreshuttle flights and more shuttle crews and, yes; more volunteers,more civilians, more teachers in space. Nothing ends here; ourhopes and our journeys continue!
(6) Implement the replace_punctuation()function. replace_punctuation() has a string parameter and twokeyword argument parameters exclamation_count andsemicolon_count. replace_punctuation() updates the stringby replacing each exclamation point (!) character with a period (.)and each semicolon (;) character with a comma (,).replace_punctuation() also counts the number of times eachcharacter is replaced and outputs those counts. Lastly,replace_punctuation() returns the updated string. Callreplace_punctuation() in the print_menu() function, and then outputthe edited string. (3 pts)
Ex: Punctuation replaced
exclamation_count: 1
semicolon_count: 2
Edited text: we'll continue our quest in space. there will be moreshuttle flights and more shuttle crews and, yes, more volunteers,more civilians, more teachers in space. nothing ends here, ourhopes and our journeys continue.
(7) Implement the shorten_space() function.shorten_space() has a string parameter and updates the string byreplacing all sequences of 2 or more spaces with a single space.shorten_space() returns the string. Call shorten_space() in theprint_menu() function, and then output the edited string. Hint:Look up and use Python function .isspace(). (3 pt)
Ex:
Edited text: we'll continue our quest in space. there will bemore shuttle flights and more shuttle crews and, yes, morevolunteers, more civilians, more teachers in space. nothing endshere; our hopes and our journeys continue!