Question: python ''' REMEMBER YOU MUST COMPLETE ALL THREE OF THESE SCRIPTS!!!! NOT JUST THIS ONE! string_funcs ========== Complete the following five functions. - print_line -
python
''' REMEMBER YOU MUST COMPLETE ALL THREE OF THESE SCRIPTS!!!! NOT JUST THIS ONE!
string_funcs ========== Complete the following five functions. - print_line - print_header - print_value_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_value_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_value_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. ''' ##### Your code goes below here #####
### UNCOMMENT THESE TO TEST YOUR FUNCITONS ### ### RECOMMENT THEM BEFORE RUNNING MAIN.PY ###
# print_line('-') # print_header('2021 Crop Report') # print_value_line('Fall 2020 Enrollment',504) # print_float_line('The value of e',2.718281828459045) # print_footer('1/1/2020','Summary Data','page 1 of 1')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
