Skip to content

Latest commit

 

History

History
119 lines (109 loc) · 1.47 KB

File metadata and controls

119 lines (109 loc) · 1.47 KB

img

Data structures: Set, tuples

Question #0

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a.append(5)
>>> len(a)
  • 6
  • 2
  • 5

Question #1

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> b = a
>>> b
  • 1
  • [1, 2, 3, 4]
  • [1]
  • a

Question #2

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a[2] = 10
>>> a
  • [1, 2, 10, 4]
  • [1, 2, 3, 4]
  • [1, 10, 3, 4]
  • [1, 2, 10, 10]

Question #3

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a[-1]
  • 4
  • -1
  • 2
  • [4, 3, 2, 1]

Question #4

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a[-3]
  • 2
  • -3
  • [4, 3]

Question #5

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a[0]
  • 1
  • [1]
  • 2
  • [1, 2, 3, 4]
  • [1, 2]

Question #6

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> b = a
>>> a[2] = 10
>>> b
  • [1, 2, 3, 4]
  • [1, 2, 10, 4]
  • 1
  • b
  • a

Question #7

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> a[1:3]
  • [2, 3]
  • [1, 2, 3]
  • [1, 2]

Question #8

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> b = a
>>> a[2] = 10
>>> a
  • [1, 2, 3, 4]
  • [1]
  • [1, 2, 10, 4]
  • b
  • a

Question #9

What do these lines print?

>>> a = [1, 2, 3, 4]
>>> len(a)
  • 6
  • 2
  • 4
  • 8