QUESTION IMAGE
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)
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.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
D. scores.append([6, 2])