Question
Answer the following question It is in python Consider the following program: import copy vals = ['a', ['b', 'c']] copy1 = vals copy2 = vals[:]
Answer the following question
It is in python
Consider the following program:
import copy vals = ['a', ['b', 'c']] copy1 = vals copy2 = vals[:] copy3 = copy.deepcopy(vals) _________ print(copy1, copy2) print(copy2, copy3)
Question 1: Fill in the blank in the program with a line of code that alters vals in a way that causes print(copy1, copy2) to print out two different lists. Your line of code must only operate on vals: you can't directly alter copy1 or copy2.
________________
Question 2: Fill in the blank in the program with a line of code that alters vals in a way that causes print(copy2, copy3) to print out two different lists. Your line of code must only operate on vals: you can't directly alter copy2 or copy3.
________________
Question 3:
copy1 is:
a shallow copy of vals
a deep copy of vals
neither
Question4:
copy2 is:
a shallow copy of vals
a deep copy of vals
neither
Question 5:
copy3 is:
a shallow copy of vals
a deep copy of vals
neither
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started