Lists MCQ Practice

Question 1 of 10

colors = ["red","green","blue"] (1-based). What is colors[2]?

  1. A. green
  2. B. blue
  3. C. 2
  4. D. red

Question 2 of 10

items=[4,8,15,16]. INSERT(items,2,99) then APPEND(items,1). Final list?

  1. A. [4, 8, 15, 16, 99, 1]
  2. B. [4, 99, 8, 15, 16, 1]
  3. C. [4, 8, 99, 15, 16, 1]
  4. D. [99, 4, 8, 15, 16, 1]

Question 3 of 10

pets=["cat","dog","bird","fish"]. REMOVE(pets,2) then REMOVE(pets,2). Final?

  1. A. ["dog", "bird"]
  2. B. ["cat", "bird"]
  3. C. ["cat", "fish"]
  4. D. ["cat", "dog"]

Question 4 of 10

nums=[10,20,30]. After INSERT(nums,1,5), LENGTH(nums)?

  1. A. 5
  2. B. 2
  3. C. 3
  4. D. 4

Question 5 of 10

bag=[2,4,6,8]. REMOVE(bag,3) then INSERT(bag,3,7). Correct after each step?

After REMOVE After INSERT
? ?
  1. A. [2, 4, 8] then [2, 4, 7, 8]
  2. B. [2, 4, 6] then [2, 4, 7, 6]
  3. C. [2, 6, 8] then [2, 6, 7, 8]
  4. D. [4, 6, 8] then [7, 4, 6, 8]

Question 6 of 10

scores=[9,9,9]. APPEND(scores,10). scores[4]?

  1. A. 9
  2. B. 10
  3. C. 4
  4. D. An error always occurs

Question 7 of 10

letters=["a","b","c","d"]. x โ† letters[3] then letters[1] โ† x. Final letters?

  1. A. ["c", "b", "a", "d"]
  2. B. ["a", "b", "c", "c"]
  3. C. ["c", "b", "c", "d"]
  4. D. ["a", "b", "a", "d"]

Question 8 of 10

q=[1,2,3]. INSERT(q,4,9) then REMOVE(q,1). Final?

  1. A. [1, 2, 9]
  2. B. [9, 2, 3]
  3. C. [2, 3, 1]
  4. D. [2, 3, 9]

Question 9 of 10

shop=["milk","eggs","bread"]. After REMOVE(shop,3), LENGTH and shop[2]?

  1. A. Length 2 and eggs
  2. B. Length 3 and eggs
  3. C. Length 2 and bread
  4. D. Length 2 and milk

Question 10 of 10

Which statement about AP CSP lists is true?

  1. A. First element is at index 0.
  2. B. First element is at index 1.
  3. C. INSERT never changes LENGTH.
  4. D. REMOVE leaves a hole at the removed index.