Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following five functions python3 - print_line - print_header - print_integer_line - print_float_line - print_footer Except as noted, you can implement the functions however

Complete the following five functions python3 - print_line - print_header - print_integer_line - print_float_line - print_footer

Except as noted, you can implement the functions however you like. I.e., you can use string functions OR f-strings to accomplish the formatting.

NOTE: These functions are not "called" in this script at all. They should be "imported" and called from main.py (done for you).

BUT: You can test each function by uncommenting out the lines at the very end. On Mimir, running python3 string_funcs.py will execute any uncommented function calls. !!!! JUST BE SURE TO COMMENT THEM BACK OUT BEFORE RUNNING MAIN.PY !!!! '''

def print_line(char): ''' Simply print a line of 60 characters. Specifically, print the 'char' that is passed in as a parameter. For example, calling:

print_line('-')

should print as follows:

------------------------------------------------------------

''' ##### Your code goes below here #####

def print_header(text): ''' Print out a header line that prints the "text" parameter such that it is centered and takes up a total of 60 characters. It should then print a second line that contains 60 "+" symbols. In other words, calling:

print_header('2021 Crop Report')

should print as follows:

2021 Crop Report ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

HINT: use print_line('+') to print out that line second line. ''' ##### Your code goes below here #####

def print_integer_line(text,value): ''' Print out a line of text where the "text" parameter is left aligned and takes up a total of 50 characters and the "value" parameter is right aligned and takes up 10 characters. In other words, calling:

print_integer_line('Fall 2020 Enrollment',504)

should result in a printed line as follows:

Fall 2020 Enrollment 504 ''' ##### Your code goes below here #####

def print_float_line(text,value): ''' Print out a line of text where the "text" parameter is left aligned and takes up a total of 45 characters and the "value" parameter is right aligned and takes up 15 characters AND is displayed as a float value with TWO decimal place. So, calling:

print_float_line('The value of e', 2.718281828459045)

will print as follows:

The value of e 2.72

''' ##### Your code goes below here #####

def print_footer(left,middle,right): ''' Print out a footer line that prints a single line of 60 "+" characters followed by a line that prints the "left", "middle" and "right" parameters such that left is aligned to the left, middle is centered, and right is aligned to the right. Each should take up 20 characters. In other words, if I call:

print_footer('1/1/2020','Summary Data','page 1 of 1')

your printed output should be:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1/1/2020 Summary Data page 1 of 1

HINT: use print_line('+') to print out that first line.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

IBM Db2 11 1 Certification Guide Explore Techniques To Master Database Programming And Administration Tasks In IBM Db2

Authors: Mohankumar Saraswatipura ,Robert Collins

1st Edition

1788626915, 978-1788626910

More Books

Students also viewed these Databases questions