Do Now 2.05
Part 1 - Open up the console
Type the following example code using interactive mode
Example 1
>>> a = [123, 'First Item', 456, 'Second Item']
>>> b = a[0:2]
>>> print(a)
>>> print(b)
In your notebook
Respond to the following
- What happens to a?
- What is b?
- What type is b?
Example 2
>>> a = [123, 'First Item', 456]
>>> a.remove('First Item')
>>> print(a)
Continue in your notebook
Respond to the following questions
- What does
remove do?
- What would the length of this list be after
remove?
Example 3
>>> a = [123, 'First Item', 456]
>>> a.pop()
>>> print(a)
Continue your responses in your notebook
- what does
pop do?
- What is the difference between
remove and pop?
Example 4
>>> a = [123, 'First Item', 456, 'Second Item']
>>> b = a + ['Third Item']
>>> print(a)
>>> print(b)
Continue your responses to the following in your notebook
- What happens to a?
- What is b?
- What type is b?
Example 5
>>> a = []
>>> print(len(a))
>>> a.append('First Item')
>>> print(a)
In your Notebook
- What was the length of
[]?
- What does
append do? What would the length be after append?
Edit this page
Report an issue