Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please, thanks! (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1

in python please, thanks!

image text in transcribedimage text in transcribed

(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 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! (2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu(function). Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters to Quit. (3 pts) Ex: w MENU C - Number of non-whitespace characters Number of words f - Fix capitalization r - Replace punctuation Shorten spaces q - Quit S Choose an option: (3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the 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 of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts) Ex: Number of words: 35 (5) Implement the fix_capitalization function, fix_capitalization has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters, fix_capitalization also returns the number of letters that have been capitalized. Call fix_capitalization in the print_menu() function, and then output the the edited string followed by the number of letters capitalized. Hint 1: Look up and use Python functions.islower() and upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string (3 pts) Ex: Number of letters capitalized: 3 Edited 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 ! (6) Implement the replace_punctuation() function.replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation updates the string by replacing each exclamation point () character with a period and each semicolon () character with a comma ().replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation) returns the updated string. Call replace_punctuation in the print menu() function, and then output the 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 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. (7) Implement the shorten_space() function, shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_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 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! 293916 1717204 0/20 main.py Load default template.. menu_op! 1 # Type all other functions here 2 3 def print_menu(usr_str): 4 5 # Complete print_menu() function 6 return menu_op, usr_str 7 8 9 if __name__ == '__main__': 10 # Complete main section of code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

ISBN: 3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

=+C&B (especially taxation) laws, regulations, and practices?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago