Answered You can hire a professional tutor to get the answer.

QUESTION

Create a function named addTables that expects two 2-dimensional tables of integers (both implemented as a list of lists) as parameters.

Create a function named addTables that expects two 2-dimensional tables of integers

(both implemented as a list of lists) as parameters. Both tables will have the same

dimensions, so your addTables function does not have to verify that the tables are the

same size. Your function should create a new table with the same dimensions as the two

tables passed as parameters. For the remainder of this explanation of how your function

should work, we'll call the two tables passed as parameters table1 and table2, and the new

table will be table3.

Once table3 has been created, your function should add the value of each element in

table1 to the value of the corresponding element of table2 and store the sum at the same

location in table3. For example, the value stored at indexes 1,2 in table3 would be the

sum of the values stored at indexes 1,2 in table1 and table2. In other words, if you think

of the first two tables as matrices, this function performs matrix addition. When the

individual values from table1 and table2 have been added and stored in table3, your

function should return the new table, table3. Your function does not ask for keyboard

input, it does not print anything, and it must not modify any of the values in table1 and

table2. Here are some examples of this function's behavior:

>>> addTables([[2,3,5],[7,9,11]],[[13,17,19],[23,29,31]])

[[15, 20, 24], [30, 38, 42]]

>>>

addTables([[1,8],[2,7],[3,6],[4,5]],[[9,16],[10,15],[11,14],[12,13]])

[[10, 24], [12, 22], [14, 20], [16, 18]]

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question