Do Now 2.06
Part 1
Open up the terminal. Type the following code using interactive mode:
>>> a = [123, 'First Item', 456, 'Second Item']
>>> b = a[0:2]
>>> print(a)
>>> print(b)
What happens to a? What is b? What type is b?
>>> a = [123, 'First Item', 456]
>>> a.remove('First Item')
>>> print(a)
What does remove
do? What would the length of this list be after remove
?
>>> a = [123, 'First Item', 456]
>>> a.pop()
>>> print(a)
What does pop
do? What is the difference between remove
and pop
?
>>> a = [123, 'First Item', 456, 'Second Item']
>>> b = a + ['Third Item']
>>> print(a)
>>> print(b)
What happens to a? What is b? What type is b?
>>> a = []
>>> print(len(a))
>>> a.append('First Item')
>>> print(a)
What was the length of []
?
What does append
do? What would the length be after append
?