Question: QUESTION 1 (25 MARKS) Write a program to print out any sized multiplication table between 1 to 20 (inclusive). A sample output (e.e, 10x10) is


QUESTION 1 (25 MARKS) Write a program to print out any sized multiplication table between 1 to 20 (inclusive). A sample output (e.e, 10x10) is shown below The main) and display heading0 functions are given below and they should not be changed in any way. Copythis code into your program. def display heading (size, spaces) display separator (size, spaces) title-str (aize) "x"+str (size)"Times Table print(get wordittle, (aize+)*spaces) print (get_zow (0, size,spaces) display separator (size, spaces) Enter the size of the multiplication table (1-20):10 10x10 Times Table 1 1 2345 6 7910 6 8 10 12 14 16 18 20 12 15 18 21 2427 30 41 48 12 16 20 24 28 32 3640 55 10 15 2025 30 35 404550 61 12 18 2430 36 42 485460 717 14 21 28 35 42 49 56 6370 91 16 24 3240 48 56 64 7280 18 2736 45 54 63 72 81 90 L010 20 30 4 50 60 70 8090 100 def nain izeget user input spaces- len (str(aize size)) +2 display heading (size, spaces) display table (size, spaces) display separator (size, spaces) main O Note that the size of the multiplication table is obtained from the user input, Le., an integer value between 1 and 20 (both inclusive) This means that the layout of the table varies according to the eiven sbe, For example, a 4x4 table and a 7x7 table will have the following different output. Note that the variable 'spaces represents the available spaces in a column for displaying a number, which is set to the length of the maximum number (i.e., size*size) plus 2 in the mainO function complete the following six functions so that the completed program runs as described above: def get_nubez (, spaces) Enter the size of the multiplication table (1-20):4 This function returns a string representation of the parameter 'num that is the same length (size) of the given spaces value with the number aligned to the right. For example, if the parameter variable num is 12 and 'spaces' is 6, the function returns a string value of spaces (where 4 (6-1en 12") on the left side of the string "12 x4 Times Table of12", which has 4 empty 212 68 313 69 12 41 48 12 16 def get_word(woeds, spaces): This function returns a string representation of the parameter 'words' that is the same length (size) of the given 'spaces' value with the words aligned in the middle. For example, if the parameter variable words' is the string helo" and 'spaces' is 15, the function returns a string value hllo which has 5 empty spaces (where 5-15-Hen"hello V/2) on each side of the word hello".Note that if the total number of empty spaces after subtracting the length of the words (from the given spaces' value is an odd number, the left hand side of the words will have one more empty space than that of the right hand side. If the length of the words is longer than the value in 'spaces', the function returns the words' itself Enter the size of the multiplication table (1-20) 7 x7 Times Table 2124 6 10 12 14 31 36 9 12 15 18 21 414812 16 20 24 28 SIS 10 15 20 25 3035 616 12 18 24 30 36 4 717 14 21 28 35 42 49 def get row(num, size, spaces): This function returns the string representation of the content of one row in the table. The content of a row consists of two parts, L.e, the number value for the row followed by the " symbol and the actual values (i.e., multiplic ation results) in that row up to the size of the table. Note that the parameter variable 'num stores the row value, the parameter 'size stores the table size and the parameter spaces' represents the length of the available space available for printing each number in a column. If the 'num value is o, it represents the row in the table heading. Otherwise, t is a row in the content of the table, where a loop structure will be needed to append the string values in each column (by calling the get number function)one by one to the resulting string. Your program must give the correct output in the same format as the outputs in the examples
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
