# Decorations.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-24 File created. # 2022-12-16 Converted to Python 3. # This is the Python version of the corresponding Java/C#/C++ # programs. The internal structure of the functions differs # in this Python version from the versions written in other # programming languages. The reason for this is that the # Python print statement usually prints an extra space character # after the text that is printed. # A comma at the end of a print statement prevents the automatic # printing of a newline character. def multiprint_character( character_from_caller, number_of_times_to_repeat ) : # We'll create a string whose length is number_of_times_to_repeat # and then we simply print that string. print( number_of_times_to_repeat * character_from_caller, end=" " ) def print_text_in_decorated_box( text_from_caller ) : text_length = len( text_from_caller ) print( "\n ", end=" " ) multiprint_character( '=', text_length + 8 ) print( "\n ", end=" " ) multiprint_character( '*', text_length + 8 ) print( "\n **", end=" " ) multiprint_character( ' ', text_length + 2 ) print( "**\n ** " + text_from_caller + " **\n **", end=" " ) multiprint_character( ' ', text_length + 2 ) print( "**\n ", end=" " ) multiprint_character( '*', text_length + 8 ) print( "\n ", end=" " ) multiprint_character( '=', text_length + 8 ) print( "\n ", end=" " ) # The main program. first_text = "Hello, world." print_text_in_decorated_box( first_text ) print_text_in_decorated_box( "I am a computer program written in Python." )