QUESTION IMAGE
Question
question: 7
which of the following programs would alter my_list to consist of the following:
red, green, blue, orange, yellow
my_list = red, green, blue, orange
my_list.append(yellow)
my_list = red, green, blue, orange
my_list.extend(yellow)
my_list = red, green, blue, orange
my_list.replace(yellow)
my_list = red, green, blue, orange
my_list.add(yellow)
Step1: Analyze initial list
Initial my_list = ['red', 'green', 'blue', 'orange'] (4 elements). Target list adds 'yellow' at end (5 elements).
Step2: Check first option
append('yellow') adds element to list end. Result: ['red', 'green', 'blue', 'orange', 'yellow'] (matches target).
Step3: Verify other options
extend('yellow')splits string into chars: adds ['y','e','l','l','o','w'] → wrong.replace('yellow')is not a Python list method → invalid.add('yellow')is not a Python list method → invalid.
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
The first option (my_list = ['red', 'green', 'blue', 'orange']; my_list.append('yellow'))