Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that potentially contains ' ' line break characters. The

def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that

def print_centered (text): that takes a string parameter text with a multi-line text, i.e., text that potentially contains ' ' 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 is the best language!") 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

I understand The question in the image is asking for a function that takes a string parameter text w... 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

Java Concepts Late Objects

Authors: Cay S. Horstmann

3rd Edition

1119186714, 978-1119186717

More Books

Students also viewed these Programming questions