134k views
5 votes
To complete function udpate_table, so that each item is increase by 3

After calling update_table function, table1 will updated to: [[3,4,5,6),[4,5,6,7],[5,6,7,8],[6,7,8,9]]. Table2 will updated to [[5,6],[4,6],[5,7],[8,9]]
def update_table(table):

def main():
tablel [[0,1,2,3], [1,2,3,4], [2,3,4,5],[3,4,5,6]]
table [[2,3],[3,3],[2,4],[5,6]]
update_table(table1)
update_table(table2)
print(table1)
print(table2)
main()

User Daedsidog
by
8.5k points

1 Answer

2 votes

Final answer:

The function update_table increases each item in a table by 3.

Step-by-step explanation:

The function udpate_table can be defined as:

def update_table(table):
for i in range(len(table)):
for j in range(len(table[i])):
table[i][j] += 3

After calling the update_table function with table1, it will be updated to:

[[3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9]]

Similarly, table2 will be updated to:

[[5, 6], [4, 6], [5, 7], [8, 9]]

User Vincy
by
7.9k points