Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.37 KB

File metadata and controls

72 lines (51 loc) · 1.37 KB

Do Now 2.05

Open up the console. Type the following example code using interactive mode:

Example 1

    a_list = [123, 'First Item', 456, 'Second Item']
    b_list = a_list[0:2]
    print(a_list)
    print(b_list)

In your notebook, respond to the following:

  1. What happens to a_list?
  2. What is in b_list?

Example 2

    a_list = [123, 'First Item', 456, 'Second Item']
    a_list.remove('First Item')
    print(a_list)

Continue in your notebook. Respond to the following questions:

  1. What does remove do?
  2. What is the length of a_list after the remove?

Example 3

    a_list = [123, 'First Item', 456, 'Second Item']
    popped_value = a_list.pop()
    print(a_list)
    print(popped_value)

Continue your responses in your notebook:

  1. what does pop do?
  2. What is the difference between remove and pop?

Example 4

    a_list = [123, 'First Item', 456, 'Second Item']
    b_list = a_list + ['Third Item']
    print(a_list)
    print(b_list)

Continue your responses to the following in your notebook:

  1. What happens to a_list?
  2. What is in b_list?

Example 5

    a_list = ['First Item']
    print(a_list)
    a_list.append('Second Item')
    print(a_list)

In your notebook, answer:

  1. What does append do?
  2. What would be the length after append?