Assessment: Sequence Mutation >> Python Basics
seqmut-1-5: Could aliasing cause potential confusion in this problem?
b = ['q', 'u', 'i']
z = b
b[1] = 'i'
z.remove('i')
print(z)
✔️ Yes, b and z reference the same list and changes are made using both aliases.
Multiple Choice (assess_question3_3_1_2)
Score: 1.0 / 1
seqmut-1-6: Could aliasing cause potential confusion in this problem?
sent = "Holidays can be a fun time when you have good company!"
phrase = sent
phrase = phrase + " Holidays can also be fun on your own!"
✔️ Since a string is immutable, aliasing won’t be as confusing. Beware of using something like item = item + new_item with mutable objects though because it creates a new object. However, when we use += then that doesn’t happen.
Multiple Choice (assess_question3_3_1_4)
Score: 1.0 / 1
seqmut-1-1: Which of these is a correct reference diagram following the execution of the following code?
lst = ['mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune', 'pluto']
lst.remove('pluto')
first_three = lst[:3]
![First Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a1_1.png)
![Second Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a1_2.png)
✔️ Yes, when we are using the remove method, we are just editing the existing list, not making a new copy.
Multiple Choice (assess_question4_1_1_1)
Score: 1.0 / 1
seqmut-1-7: Which of these is a correct reference diagram following the execution of the following code?
x = ["dogs", "cats", "birds", "reptiles"]
y = x
x += ['fish', 'horses']
y = y + ['sheep']
![First Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a3_1.png)
![Second Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a3_2.png)
![Third Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a3_3.png)
![Fourth Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a3_4.png)
✔️ Yes, the behavior of obj = obj + object_two is different than obj += object_two when obj is a list. The first version makes a new object entirely and reassigns to obj. The second version changes the original object so that the contents of object_two are added to the end of the first.
Multiple Choice (assess_question3_3_1_5)
Score: 1.0 / 1
seqmut-1-8: Which of these is a correct reference diagram following the execution of the following code?
sent = "The mall has excellent sales right now."
wrds = sent.split()
wrds[1] = 'store'
new_sent = " ".join(wrds)
![First Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a2_1.png)
![Second Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a2_2.png)
![Third Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a2_3.png)
![Fourth Potential Solution](https://fopp.umsi.education/books/published/fopp/_images//week3a2_4.png)
✔️ Yes, when we make our own diagrams we want to keep the old information because sometimes other variables depend on them. It can get cluttered though if there is a lot of information.