Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question # 4 multiple choice your program has a two - dimensional array…

Question

question # 4
multiple choice
your program has a two - dimensional array, scores. you are implementing your array with lists. each member in the array is a pair of scores, composed of your team score, the opponents score. which line of code will add a new pair of scores to the array?
○ scores.insert(6, 2)
○ scores.insert6, 2
○ scores.append(6, 2)
○ scores.append(6, 2)

Explanation:

Brief Explanations

In Python, when using lists to represent a two - dimensional array and wanting to add a new pair (which should be a list itself in this context) to the end of the outer list, the append method is used. The new pair should be passed as a list. scores.insert inserts at a specific index and scores.append((6, 2)) tries to append a tuple instead of a list as required. The correct syntax is scores.append([6, 2]) to add a new list (pair of scores) to the scores list.

Answer:

D. scores.append([6, 2])