def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that potentially contains '\n' line break characters. The function prints the string centered and enclosed in a box of "*". For text with no line breaks (single-line), the function just prints the text in a box. For example, print_centered ("Python rocks!") should print: * Python rocks! create the following function: If the text contains multiple lines, each line will be centered and the entire text is enclosed in a box. For example, print_centered("Python\nis\nthe\nbest\nlanguage!") should print: . Python is the best * language! * ******** You may NOT use the .center() string method. Hints: . If any line within the text starts or ends with spaces or tabs, you may need to remove them before you center the line. You can use the strip() string method to do that. In the same file, also create a main program that calls the print_centered function to print a multi-line text of your choice. You can hard-code the text in your program. This is just to demonstrate that your print_centered function works correctly. def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that potentially contains '\n' line break characters. The function prints the string centered and enclosed in a box of "*". For text with no line breaks (single-line), the function just prints the text in a box. For example, print_centered ("Python rocks!") should print: * Python rocks! create the following function: If the text contains multiple lines, each line will be centered and the entire text is enclosed in a box. For example, print_centered("Python\nis\nthe\nbest\nlanguage!") should print: . Python is the best * language! * ******** You may NOT use the .center() string method. Hints: . If any line within the text starts or ends with spaces or tabs, you may need to remove them before you center the line. You can use the strip() string method to do that. In the same file, also create a main program that calls the print_centered function to print a multi-line text of your choice. You can hard-code the text in your program. This is just to demonstrate that your print_centered function works correctly.
Expert Answer:
Answer rating: 100% (QA)
I understand The question in the image is asking for a function that takes a string parameter text w... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Braverman Company has two manufacturing departments-Finishing and Fabrication. The predetermined overhead rates in Finishing and Fabrication are $22.00 per direct labor-hour and 120% of direct...
-
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...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
9) The mole (Avogadro number N) is defined as the number of atoms in exactly 12 grams of 2C, calculate the: a) number of atoms in 2 g of C b) number of atoms in 5 g of C
-
A plumber applies a 220-N force to the handle of a wrench as she removes a coupling from the end of a pipe. Knowing that the wrench and the force lie in a vertical plane parallel to the yz plane,...
-
Given that there are 2 shaftments in a foot, 1 . 5 feet in a cubit, 2 cubits in a yard, and 2 yards in a fathom, how many shaftments are there in 2 . 0 fathoms?
-
This creative dynamic visualization by Nathan Yau (flowingdata.com) shows a day in the life of 1000 different representative Americans based on survey data: http://flowingdata...
-
El Paso Products Company has accumulated the following data over a six-month period: Separate the machine-related costs into their fixed and variable components, using the high-low method. Machine...
-
Use the triangle diagrams to help complete the table for the exact trig values. 0 30 45 60 90 0 1 0 45 2 3 2 sin Cos 1 45 60 1 1 tan 0 Section B: Give the exact values. 1) sin 30+ cos 60 4) 2sin 60...
-
Dwight Donovan, the president of Donovan Enterprises, is considering two investment opportunities. Because of limited resources, he will be able to invest in only one of them. Project A is to...
-
Victor Finick likes to have the same amount of x as he has of y.The utility function of it is U(x, y) = min {2x y, 2y x}. to.Draw Victor's indifference curve that passes through the basket (0, 0) and...
-
Provide two examples of how the ACA has influenced employer-sponsored health insurance plans and WHPs.
-
What are ways to make out-of-home vehicles both interactive and engaging?
-
What is retail advertising and how is it used in an IMC campaign?
-
To make a sale, newspaper advertising must instill a sense of urgency. In what ways can this be accomplished?
-
Why are magazines considered highly targetable?
-
Look at the (2020 and 2021/22)annual report of tesla and write a note on the earnings management techniques such as Big bath, cookie jae reserves, operating activities, materiality, and revenue...
-
Find i 0 (t) for t > 0 in the circuit in Fig. 16.72 . 2 + Vo 1 7.5e-2t u(t) V ( +) 4.5[1 u(t)]V 0.5v. 1H
-
Solve Exercise E8.11 by implementing classes Sphere, Cylinder, and Cone. Which approach is more object-oriented? Data from Exercise E8.11 Write static methods public static double...
-
When browsing through the Java documentation for more information about sliders, we ignored the JSlider constructor with no arguments. Why? Would it have worked in our sample program?
-
Write a program that keeps a map in which both keys and values are stringsthe names of students and their course grades. Prompt the user of the program to add or remove students, to modify grades, or...
-
What is the present value of the following future amounts? a. $805 to be received 10 years from now discounted back to the present at 10 percent b. $376 to be received 5 years from now discounted...
-
To what amount will the following investments accumulate? a. $6,000 invested for 12 years at 12 percent compounded annually b. $7,500 invested for 8 years at 8 percent compounded annually c. $6,400...
-
At what annual rate would the following have to be invested? a. \($820\) to grow to \($1,988.12\) in 13 years b. \($320\) to grow to \($423.10\) in 6 years c. \($57\) to grow to \($290.30\) in 18...
Study smarter with the SolutionInn App