Write a function named q2() with no parameters and no return value. Inside the q2() function,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
• Write a function named q2() with no parameters and no return value. Inside the q2() function, you can write your own functions to accomplish the following tasks: 1. Create an empty list that will be used to store words. Read each word from the input. Each word is input on a separate line. The string lend on a new line indicates the end of words. DO NOT PRINT ANYTHING YET. 2. Create another empty list that will be used to store user input, which will be in text format. Input text may contain many words; the text may be on separate input lines. The end of text is indicated by the string lend on a new line. DO NOT PRINT ANYTHING YET 3. The text in part 2) above may contain any of the following, and no other, punctuation marks: period (), comma (.), question mark (?), and exclamation point (!). Replace each punctuation mark in the text by a space. DO NOT PRINT ANYTHING YET. 4. Mutate the text you have in part 2) by replacing each word in the text by reverse but only if the word appears in the list of words input in a). For example, reverse of "Hello" is "olleH". 5. Print the mutated text. Hints: • Use the string replace() function to remove punctuation marks and lend from the text. • Use the string remove() function to remove the string lend from the list of words. • Use string slicing to obtain a reverse of a word. Test your program using the following test case, and many more that you may construct yourself. Input to your program from the keyboard: Hello are you lend Hello dear! How are you doing? lend Output from your program on the screen: olleH dear How era uoy doing • Write a function named q2() with no parameters and no return value. Inside the q2() function, you can write your own functions to accomplish the following tasks: 1. Create an empty list that will be used to store words. Read each word from the input. Each word is input on a separate line. The string lend on a new line indicates the end of words. DO NOT PRINT ANYTHING YET. 2. Create another empty list that will be used to store user input, which will be in text format. Input text may contain many words; the text may be on separate input lines. The end of text is indicated by the string lend on a new line. DO NOT PRINT ANYTHING YET 3. The text in part 2) above may contain any of the following, and no other, punctuation marks: period (), comma (.), question mark (?), and exclamation point (!). Replace each punctuation mark in the text by a space. DO NOT PRINT ANYTHING YET. 4. Mutate the text you have in part 2) by replacing each word in the text by reverse but only if the word appears in the list of words input in a). For example, reverse of "Hello" is "olleH". 5. Print the mutated text. Hints: • Use the string replace() function to remove punctuation marks and lend from the text. • Use the string remove() function to remove the string lend from the list of words. • Use string slicing to obtain a reverse of a word. Test your program using the following test case, and many more that you may construct yourself. Input to your program from the keyboard: Hello are you lend Hello dear! How are you doing? lend Output from your program on the screen: olleH dear How era uoy doing
Expert Answer:
Answer rating: 100% (QA)
Python program that reverses the words in an input sentence import ... View the full answer
Related Book For
Artificial Intelligence A Modern Approach
ISBN: 9780134610993
4th Edition
Authors: Stuart Russell, Peter Norvig
Posted Date:
Students also viewed these programming questions
-
Consider a graph with soda on the vertical axis and pizza on the horizontal axis if the country pre-trade national equilibrium relative price of pizza is 3 soda then the slope of the production...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Hyten Corporation On June 5, 1998, a meeting was held at Hyten Corporation, between Bill Knapp, Director of Marketing/Sales, and John Rich, director of engineering. The purpose of the meeting was to...
-
Factor completely. p(p + 2) + p(p + 2) - 6(p + 2)
-
Find the conformations in Figure 3.4 in which the red circles are (a) Gauche and (b) Anti.
-
Two spheres are each rotating at an angular speed of 24 rad/s about axes that pass through their centers. Each has a radius of 0.20 m and a mass of 1.5 kg. However, as the figure shows, one is solid...
-
Air at \(200^{\circ} \mathrm{F}\) and 60 psia flows in a 4-in.-diameter pipe at a rate of \(0.52 \mathrm{lb} / \mathrm{s}\). Determine the pressure at the 2-in.-diameter throat of a Venturi meter...
-
Based on the PLC, what challenges does Samsung face in managing its high-tech products? In the world of consumer electronics, copycat brands are a dime a dozen. These are the brands consumers turn to...
-
Explain: Standard cost ideal standard vs practical standard Talk about Flexible budget+ (+ Variances actual) Do you will use ideal standard in the accounting computation? Target costing (pricing) +...
-
Consider the equilibrium NO 2 (g) NO(g) + 1/2O 2 (g). One mole of NO 2 (g) is placed in a vessel and allowed to come to equilibrium at a total pressure of 1 bar. An analysis of the contents of the...
-
A 335 room hotel forecasts its average room rate to be $145 for the next year with an 77% Occupancy rate. The hotel is open 365 days a year. The hotel department has a fixed wage cost with benefits...
-
As a Project Manager, Product Owner or Scrum Master of an Agile Project, how would having a "fixed" mindset (lacking flexibility to adapt to change) about the project deliverables impact the project?...
-
please solve this question Given one of the address in the block is 192.168.1.10/25 1) Provide the address in binary number notation 2) Represent the mask as a 32 bits binary number 3) What is the...
-
Ming has income m and the utility function u(x1, x2) = 8x1 - (x1)+ x2 where and 2 are the quantities of the two goods consumed. The price of good 1 is p and the price of good 2 is p2 = 1. (a) Find...
-
1. Select a company and analyze how at least three (3) of its internal functions (e.g., Management, marketing, and R&D) negatively or positively contribute to the implementation of its strategy or...
-
1. The market for products designed for young adults in North America is expand- ing. Provided is a stemplot of the percents of residents aged 25-35 in select Canadian cities for 2012 as estimated by...
-
What are the Filipinos traditional dress?
-
What are the 5 Cs of marketing channel structure?
-
For the graphs in Figure S13.3, what is the minimal set of edges that must be removed such that the corresponding independence relations are guaranteed to be true? Figure S13.3 E (a) A B|F AFD BIC B...
-
In which settings is particle filtering better than exact HMM inference? Large vs. Small state spaces. Prioritizing runtime vs. accuracy.
-
Run a notebook such as www.tensorflow.org/tutorials/text/word2vec that learns word embeddings from a corpus using the skip-gram approach. Train the model on a corpus of Shakespeare, and separately on...
-
Describe the process of going public using an IPO, starting with underwriter selection and proceeding through the various stages that lead to determination of an issue price.
-
Identify at least four methods by which investors and/or the entrepreneur in a new venture can harvest their investment in a new venture. Describe the costs and benefits of each, and provide a...
-
From the perspective of the entrepreneur, what are the pros and cons of an IPO as opposed to private sale of the venture to a public company in exchange for stock or cash?
Study smarter with the SolutionInn App