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)
-
Refer to the financial statements for Chipotle reproduced in the chapter and answer the following questions. 1. What was the company's net income for 2015? 2. State Chipotle's financial position on...
-
Plot the FRED data on gross federal debt held by the public as a percent of GDP for the United States. In which periods within the postwar era did the United States experience prolonged declines in...
-
Use the prime factorizations of 36,66 , and 250 to identify the LCM.
-
International Capital, Inc. (IC), is a small investment banking firm that specializes in securing funds for small- to medium-sized firms. IC is able to use a standardized project format for each...
-
Company Profile Modco was founded in 1960, with the opening of the first Modco discount store, and was incorporated as Modco Stores Inc. in January 1970. The company's shares were listed on the NYSE...
-
Raleigh Medical Clinic is considering acquiring 2 new ultrasound machines for $300,000. The clinic estimates that the machines will have an economic life of 4 years after which they will have zero...
-
Can you identify a company with choice with a B2B sales model and one with a B2C sales model. With an Introduction, Discussion, illustration and Conclusion that the impact of supply chain when...
-
_____ measures a theoretical concept or trait that is not directly observable.
-
What role can a warehouse play in postponement strategies?
-
_____ is an assessment of whether a test measures knowledge or understanding of the items it is supposed to measure.
-
_____ is the consistency of a test measurement.
-
How do warehouses perform assortment?
-
nits sold 1,110 Price $ 10 Sales $ 11,100 Variable manufacturing costs 4,440 Fixed manufacturing costs 2,220 Variable selling costs 1,110 Fixed administrative costs 1,110 Required: Using the data...
-
Is it a breach of fiduciary duty for a director of a real estate investment trust (REIT) negotiating a joint venture on behalf of the REIT with another director for the development of a portfolio of...
-
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...
-
Lessee Company enters into a 6-year finance lease of non-specialized equipment with Lessor Company on January 1,2020 . Lessee has agreed to pay \(\$ 28,000\) annually beginning immediately on January...
-
Frontier Inc. enters into an 8 -year lease contract to lease equipment with a useful life of 8 years. Annual lease payments are due with the first payment made immediately on January 1, 2020, the...
-
Referring to the information in Brief Exercise 17-28, assume the same information except that the lessee guaranteed the residual value for \(\$ 5,000\) at the end of the lease term. Compute the value...
Study smarter with the SolutionInn App