Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

STRING_FUNCS.PY REMEMBER YOU MUST COMPLETE ALL THREE OF THESE SCRIPTS!!!! NOT JUST THIS ONE! 3 4 string_funcs 5 ========== 6 Complete the following five functions.

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribedSTRING_FUNCS.PYimage text in transcribedimage text in transcribedimage text in transcribed

REMEMBER YOU MUST COMPLETE ALL THREE OF THESE SCRIPTS!!!! NOT JUST THIS ONE! 3 4 string_funcs 5 ========== 6 Complete the following five functions. 7 print_line 8 print_header 9 print_value_line 10 print_float_line 11 - print_footer 12 13 Except as noted, you can implement the functions however you like. I.e., you 14 can use string functions OR f-strings to accomplish the formatting. 15 16 NOTE: These functions are not "called" in this script at all. They should be 17 "imported" and called from main.py (done for you). 18 19 BUT: You can test each function by uncommenting out the lines at the very end. On 20 Mimir, running python3 string_funcs.py will execute any uncommented function calls. 21 !!!! JUST BE SURE TO COMMENT THEM BACK OUT BEFORE RUNNING MAIN.PY !!!! 22 23 24.def print_line (char):|| 25 26 27 Simply print a line of 60 characters. Specifically, print the 'char' that 28 - is passed in as a parameter. For example, calling: 29 30 print_line('-') 31 32 - should print as follows: 33 34 35 36 37 ##### Your code goes below here ##### 38 - for i in range(60): 39 print(char, end='') 40 print() 41 42 44 def print_header(text): 45 46 Print out a header line that prints the "text" parameter such that it is 47 centered and takes up a total of 60 characters. It should then print a 48- second line that contains 60 "+" symbols. In other words, calling: 49 50 print_header('2021 Crop Report') 51 52 should print as follows: 53 54 2021 Crop Report 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 57 HINT: use print_line('+') to print out that line second line. 58 59 ##### Your code goes below here ##### 60 print(text.center (60,' ')) 61 print_line('+') 62 63 64 65 def print_value_line (text,value): 66 67 Print out a line of text where the "text" parameter is left aligned and takes 68 up a total of 50 characters and the "value" parameter is right aligned and 69 - takes up 10 characters. In other words, calling: 70 71 print_value_line('Fall 2020 Enrollment',504) 72 73 - should result in a printed line as follows: 74 75 Fall 2020 Enrollment 504 76 77 ##### Your code goes below here ##### 78 print(text. ljust(50,' '), end='') 79 print(str(value).rjust(10,' ')) 80 81 82 83 def print_float_line (text, value): 84 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) 85 86 87 88 - 89 90 91 92- 93 94 95 96 97 98 99 will print as follows: The value of e 2.72 ##### Your code goes below here ##### print(text. ljust(45,' '), end='') print("{0:15.2f}".format(value)) 100 101 102 103 - def print_footer(left,middle,right): 104 105 Print out a footer line that prints a single line of 60 "+" characters followed 106 by a line that prints the "left", "middle" and "right" parameters such that 107 left is aligned to the left, middle is centered, and right is aligned to the 108 right. Each should take up 20 characters. In other words, if I call: 109 110 print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 111 112 - your printed output should be: 113 114 115 1/1/2020 Summary Data page 1 of 1 116 117 HINT: use print_line("+') to print out that first line. 118 119 ##### Your code goes below here ##### 120 print_line('+') 121 print() 122 print(left. ljust(20,' '),end='') 123 print(middle.center (20,' '), end='') 124 print(right.rjust(20,' ')) 125 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 126 127 128 129 130 ### UNCOMMENT THESE TO TEST YOUR FUNCITONS ### 131 ### RECOMMENT THEM BEFORE RUNNING MAIN.PY ### 132 133 # print_line('-'). 134 # print_header('2021 Crop Report'). 135 # print_value_line ('Fall 2020 Enrollment',504) 136 # print_float_line ('The value of e', 2.718281828459045) 137 # print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 138 21 !!!! JUST BE SURE TO COMMENT THEM BACK OUT BEFORE RUNNING MAIN.PY !!!! 22 23 24.def print_line (char):| 25 26 27 Simply print a line of 60 characters. Specifically, print the 'char' that 28 - is passed in as a parameter. For example, calling: 29 30 print_line('-') 31 32 should print as follows: 33 34 35 36 37 ##### Your code goes below here ##### 38 for i in range(60): 39 print(char,end='') 40 print() 41 42 43 44 - def print_header(text): 45 46 Print out a header line that prints the "text" parameter such that it is 47 centered and takes up a total of 60 characters. It should then print a 48 - second line that contains 60 "+" symbols. In other words, calling: 49 50 print_header('2021 Crop Report) 51 52 - should print as follows: 53 54 2021 Crop Report 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 57 HINT: use print_line('+') to print out that line second line. 58 59 ##### Your code goes below here ##### 60 print(text.center (60,' ')) 61 print_line('+') 62 65 - def print_value_line (text,value): 66 67 Print out a line of text where the "text" parameter is left aligned and takes 68 up a total of 50 characters and the "value" parameter is right aligned and 69 - takes up 10 characters. In other words, calling: 70 71 print_value_line('Fall 2020 Enrollment',504) 72 73- should result in a printed line as follows: 74 75 Fall 2020 Enrollment 504 76 77 ##### Your code goes below here ##### 78 print(text. ljust(50,' '),end='') 79 print(str(value).rjust(10,' ')) 80 81 82 83. def print_float_line (text,value): 84 85 Print out a line of text where the "text" parameter is left aligned and takes 86 up a total of 45 characters and the "value" parameter is right aligned and 87 takes up 15 characters AND is displayed as a float value with TWO decimal 88 - place. So, calling: 89 90 print_float_line ('The value of e', 2.718281828459045) 91 92 - will print as follows: 93 94 The value of e 2.72 95 96 97 ##### Your code goes below here ##### 98 print(text. ljust(45,' '),end='') 99 print("{0:15.2f}".format(value)) 100 101 102 103 - def print_footer(left,middle, right): 104 102 103 - def print_footer(left,middle,right): 104 105 Print out a footer line that prints a single line of 60 "+" characters followed 106 by a line that prints the "left", "middle" and "right" parameters such that 107 left is aligned to the left, middle is centered, and right is aligned to the 108 - right. Each should take up 20 characters. In other words, if I call: 109 110 print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 111 112- your printed output should be: 113 114 +++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++ 115 1/1/2020 Summary Data page 1 of 1 116 117 HINT: use print_line('+') to print out that first line. 118 119 ##### Your code goes below here ##### 120 print_line("+') 121 print() 122 print(left. ljust(20,' '), end='') 123 print(middle.center (20,' '), end='') 124 print(right.rjust(20,' ')) 125 126 127 128 129 130 ### UNCOMMENT THESE TO TEST YOUR FUNCITONS ### 131 ### RECOMMENT THEM BEFORE RUNNING MAIN.PY 132 133 # print_line('-') 134 # print_header('2021 Crop Report') 135 # print_value_line ('Fall 2020 Enrollment',504) 136 # print_float_line ('The value of e', 2.718281828459045) 137 # print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 138 ### REMEMBER YOU MUST COMPLETE ALL THREE OF THESE SCRIPTS!!!! NOT JUST THIS ONE! 3 4 string_funcs 5 ========== 6 Complete the following five functions. 7 print_line 8 print_header 9 print_value_line 10 print_float_line 11 - print_footer 12 13 Except as noted, you can implement the functions however you like. I.e., you 14 can use string functions OR f-strings to accomplish the formatting. 15 16 NOTE: These functions are not "called" in this script at all. They should be 17 "imported" and called from main.py (done for you). 18 19 BUT: You can test each function by uncommenting out the lines at the very end. On 20 Mimir, running python3 string_funcs.py will execute any uncommented function calls. 21 !!!! JUST BE SURE TO COMMENT THEM BACK OUT BEFORE RUNNING MAIN.PY !!!! 22 23 24.def print_line (char):|| 25 26 27 Simply print a line of 60 characters. Specifically, print the 'char' that 28 - is passed in as a parameter. For example, calling: 29 30 print_line('-') 31 32 - should print as follows: 33 34 35 36 37 ##### Your code goes below here ##### 38 - for i in range(60): 39 print(char, end='') 40 print() 41 42 44 def print_header(text): 45 46 Print out a header line that prints the "text" parameter such that it is 47 centered and takes up a total of 60 characters. It should then print a 48- second line that contains 60 "+" symbols. In other words, calling: 49 50 print_header('2021 Crop Report') 51 52 should print as follows: 53 54 2021 Crop Report 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 57 HINT: use print_line('+') to print out that line second line. 58 59 ##### Your code goes below here ##### 60 print(text.center (60,' ')) 61 print_line('+') 62 63 64 65 def print_value_line (text,value): 66 67 Print out a line of text where the "text" parameter is left aligned and takes 68 up a total of 50 characters and the "value" parameter is right aligned and 69 - takes up 10 characters. In other words, calling: 70 71 print_value_line('Fall 2020 Enrollment',504) 72 73 - should result in a printed line as follows: 74 75 Fall 2020 Enrollment 504 76 77 ##### Your code goes below here ##### 78 print(text. ljust(50,' '), end='') 79 print(str(value).rjust(10,' ')) 80 81 82 83 def print_float_line (text, value): 84 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) 85 86 87 88 - 89 90 91 92- 93 94 95 96 97 98 99 will print as follows: The value of e 2.72 ##### Your code goes below here ##### print(text. ljust(45,' '), end='') print("{0:15.2f}".format(value)) 100 101 102 103 - def print_footer(left,middle,right): 104 105 Print out a footer line that prints a single line of 60 "+" characters followed 106 by a line that prints the "left", "middle" and "right" parameters such that 107 left is aligned to the left, middle is centered, and right is aligned to the 108 right. Each should take up 20 characters. In other words, if I call: 109 110 print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 111 112 - your printed output should be: 113 114 115 1/1/2020 Summary Data page 1 of 1 116 117 HINT: use print_line("+') to print out that first line. 118 119 ##### Your code goes below here ##### 120 print_line('+') 121 print() 122 print(left. ljust(20,' '),end='') 123 print(middle.center (20,' '), end='') 124 print(right.rjust(20,' ')) 125 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 126 127 128 129 130 ### UNCOMMENT THESE TO TEST YOUR FUNCITONS ### 131 ### RECOMMENT THEM BEFORE RUNNING MAIN.PY ### 132 133 # print_line('-'). 134 # print_header('2021 Crop Report'). 135 # print_value_line ('Fall 2020 Enrollment',504) 136 # print_float_line ('The value of e', 2.718281828459045) 137 # print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 138 21 !!!! JUST BE SURE TO COMMENT THEM BACK OUT BEFORE RUNNING MAIN.PY !!!! 22 23 24.def print_line (char):| 25 26 27 Simply print a line of 60 characters. Specifically, print the 'char' that 28 - is passed in as a parameter. For example, calling: 29 30 print_line('-') 31 32 should print as follows: 33 34 35 36 37 ##### Your code goes below here ##### 38 for i in range(60): 39 print(char,end='') 40 print() 41 42 43 44 - def print_header(text): 45 46 Print out a header line that prints the "text" parameter such that it is 47 centered and takes up a total of 60 characters. It should then print a 48 - second line that contains 60 "+" symbols. In other words, calling: 49 50 print_header('2021 Crop Report) 51 52 - should print as follows: 53 54 2021 Crop Report 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 57 HINT: use print_line('+') to print out that line second line. 58 59 ##### Your code goes below here ##### 60 print(text.center (60,' ')) 61 print_line('+') 62 65 - def print_value_line (text,value): 66 67 Print out a line of text where the "text" parameter is left aligned and takes 68 up a total of 50 characters and the "value" parameter is right aligned and 69 - takes up 10 characters. In other words, calling: 70 71 print_value_line('Fall 2020 Enrollment',504) 72 73- should result in a printed line as follows: 74 75 Fall 2020 Enrollment 504 76 77 ##### Your code goes below here ##### 78 print(text. ljust(50,' '),end='') 79 print(str(value).rjust(10,' ')) 80 81 82 83. def print_float_line (text,value): 84 85 Print out a line of text where the "text" parameter is left aligned and takes 86 up a total of 45 characters and the "value" parameter is right aligned and 87 takes up 15 characters AND is displayed as a float value with TWO decimal 88 - place. So, calling: 89 90 print_float_line ('The value of e', 2.718281828459045) 91 92 - will print as follows: 93 94 The value of e 2.72 95 96 97 ##### Your code goes below here ##### 98 print(text. ljust(45,' '),end='') 99 print("{0:15.2f}".format(value)) 100 101 102 103 - def print_footer(left,middle, right): 104 102 103 - def print_footer(left,middle,right): 104 105 Print out a footer line that prints a single line of 60 "+" characters followed 106 by a line that prints the "left", "middle" and "right" parameters such that 107 left is aligned to the left, middle is centered, and right is aligned to the 108 - right. Each should take up 20 characters. In other words, if I call: 109 110 print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 111 112- your printed output should be: 113 114 +++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++ 115 1/1/2020 Summary Data page 1 of 1 116 117 HINT: use print_line('+') to print out that first line. 118 119 ##### Your code goes below here ##### 120 print_line("+') 121 print() 122 print(left. ljust(20,' '), end='') 123 print(middle.center (20,' '), end='') 124 print(right.rjust(20,' ')) 125 126 127 128 129 130 ### UNCOMMENT THESE TO TEST YOUR FUNCITONS ### 131 ### RECOMMENT THEM BEFORE RUNNING MAIN.PY 132 133 # print_line('-') 134 # print_header('2021 Crop Report') 135 # print_value_line ('Fall 2020 Enrollment',504) 136 # print_float_line ('The value of e', 2.718281828459045) 137 # print_footer('1/1/2020', 'Summary Data', 'page 1 of 1') 138 ###

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

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago