(1) Prompt the user to enter a string of their choosing Store the text in a string Output the string

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Python please

(1) Prom t the user to enter
Ex:
Ex
Enter
we'll continue
quest in space. there will be none shuttle flights and more shuttle creWS and,
more volunteers, more civilians, more teachers
Space. nothing ends here; OUr
and our journeys continue!
ſou entered: we'll continue our quest in
Dace. there will
shuttle crews and, yes; more volunteers, more civilians
ends here; our hopes and our journeys continuel
ME
V
Ex:
(2) Implement the print menu() function to print the following command menu
MENU
Ex:
sample text:
Replace punctuation
Shorten spaces
Uit
(3) Implement the executa man nu() function that takes
parameters: a character representing
the user's choice and the user provided sample text._ execute menu() performs the meru
options, according to the user's choice, by calling the appropriate functions described below. (
lumber of non whitespace characters
Number of words
ix capitalization
the main program, call print menu() and prompt for the user's choice of menu options for
analyzing/editing the string Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a valid choice. when
valid option is
entered, execute the option by calling execute. menu(). Then, print the menu and prompt for a
new option. Continue until the user enters 'q'. Hint. implement Quit before implementing other
options. (1 pt)
Choose an option:
Number of non-
Number of words
ix capitalization
Replace
Shorten spaces
MENU
Ex:
string of their choosing. Stone the text in
unctuation
plement the
of
NON
get NUM
characters () has a string parameter and returns the
characters in the string, excluding all whitespace. Call get
execute menu() function, and then output the returned value. (4 pts)
Quit
Ex:
Number of non-whites pace characters
Number of words
ix capitalization
Replace punctuation
Shorten
▪hitespace characters
returns
Ex
hoose an option:
Number of non whites pace characters: 181
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!
paces
Number of words
You entered: we'll continue our quest in space. there will be more shuttle flights and more
shuttle crews
more volunteers, more civilians, more teachers in space. nothing
ends here; our hopes and our journeys continuel
(6) Implement the get
and
returns the number of words
for the last word in a sentence. Call get
then output the returned value. (3 pts)
aracte
=
MWO ords () function. get
the string-
Punctuation replaced
exclamation
COUnt:
tring
More e shuttle flights and more
More teachers in space. nothing
function.
semicolon COUnt:
Edited text: we'll continue our ques
crews and,
More volunteers
utput the string-
and our journeys Continue.
Implement the fix capitalization() function. fix capitalization() has
string parameter and
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
capitalization() in the execute menu() function, and then output the num
of lellers capitalized followed by the ediled sting-
1. Look up and use Pytron fonctions
.is/owerd
uppend to complete this task. Hōnt 2: Create an empty string and use string
concatenation to ake edits to the string. (3 pts)
capitalized. Call fix
space. There will
nur
ber of
characters() in the
More civilians
um_of_words() has a string pa
end voren a space
reached except
words() in the execute menu() function, and
Number of letters capitalized:
Edited text: We'll continue OUr quest
More shuttle flights and More
shuttle crews and,
more volunteers, more civilians, more teachers
space. Nothing
ends here;
and our journeys Continuel
(8) Implement the replace punctuation() function. replace punctuation() has a string parameter
and two keyword arg Ument parameters exclamation COUnt and semicolon COLnt
replace punctuation() updates the string by replacing each exclamation point (1) character with
period (-) and each
emicolon (;) 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
execute. menu() function, and then output the edited string. (3 pts)
ameter
ber
space. there will be more S iuttle flights and More shuttle
more teachers
space. nothing ends here,
(9) Implement the shorten space() function. shorten
pace() has a string parameter and
updates the string by replacing all sequences of 2 or more
with a single space.
shorten space() returns the string. Call shorten space() in the execute _menu() function, and
then output the edited string. Hint- Look up and use Python function isspaced. (3 pt)
Transcribed Image Text:(1) Prom t the user to enter Ex: Ex Enter we'll continue quest in space. there will be none shuttle flights and more shuttle creWS and, more volunteers, more civilians, more teachers Space. nothing ends here; OUr and our journeys continue! ſou entered: we'll continue our quest in Dace. there will shuttle crews and, yes; more volunteers, more civilians ends here; our hopes and our journeys continuel ME V Ex: (2) Implement the print menu() function to print the following command menu MENU Ex: sample text: Replace punctuation Shorten spaces Uit (3) Implement the executa man nu() function that takes parameters: a character representing the user's choice and the user provided sample text._ execute menu() performs the meru options, according to the user's choice, by calling the appropriate functions described below. ( lumber of non whitespace characters Number of words ix capitalization the main program, call print menu() and prompt for the user's choice of menu options for analyzing/editing the string Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. when valid option is entered, execute the option by calling execute. menu(). Then, print the menu and prompt for a new option. Continue until the user enters 'q'. Hint. implement Quit before implementing other options. (1 pt) Choose an option: Number of non- Number of words ix capitalization Replace Shorten spaces MENU Ex: string of their choosing. Stone the text in unctuation plement the of NON get NUM characters () has a string parameter and returns the characters in the string, excluding all whitespace. Call get execute menu() function, and then output the returned value. (4 pts) Quit Ex: Number of non-whites pace characters Number of words ix capitalization Replace punctuation Shorten ▪hitespace characters returns Ex hoose an option: Number of non whites pace characters: 181 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! paces Number of words You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continuel (6) Implement the get and returns the number of words for the last word in a sentence. Call get then output the returned value. (3 pts) aracte = MWO ords () function. get the string- Punctuation replaced exclamation COUnt: tring More e shuttle flights and more More teachers in space. nothing function. semicolon COUnt: Edited text: we'll continue our ques crews and, More volunteers utput the string- and our journeys Continue. Implement the fix capitalization() function. fix capitalization() has string parameter and 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 capitalization() in the execute menu() function, and then output the num of lellers capitalized followed by the ediled sting- 1. Look up and use Pytron fonctions .is/owerd uppend to complete this task. Hōnt 2: Create an empty string and use string concatenation to ake edits to the string. (3 pts) capitalized. Call fix space. There will nur ber of characters() in the More civilians um_of_words() has a string pa end voren a space reached except words() in the execute menu() function, and Number of letters capitalized: Edited text: We'll continue OUr quest More shuttle flights and More shuttle crews and, more volunteers, more civilians, more teachers space. Nothing ends here; and our journeys Continuel (8) Implement the replace punctuation() function. replace punctuation() has a string parameter and two keyword arg Ument parameters exclamation COUnt and semicolon COLnt replace punctuation() updates the string by replacing each exclamation point (1) character with period (-) and each emicolon (;) 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 execute. menu() function, and then output the edited string. (3 pts) ameter ber space. there will be more S iuttle flights and More shuttle more teachers space. nothing ends here, (9) Implement the shorten space() function. shorten pace() has a string parameter and updates the string by replacing all sequences of 2 or more with a single space. shorten space() returns the string. Call shorten space() in the execute _menu() function, and then output the edited string. Hint- Look up and use Python function isspaced. (3 pt)
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education