Quiz Catalog

Catalog of quizzes

a = [1, 2, 3]
b = a[:]

print(a == b, id(a) == id(b))
True False
  • object/identify

a = [5, 3, []]
b = [5, 3, []]

print(a[-1] is b[-1])
False
  • object/identify

x = ["name", "id", "balance", "date"]
x1 = x[:]
x2 = x.copy()

print(x1 == x2, x1 is x2)
True False
  • object/compare
  • object/identify

h = "Hola"
el1 = set(h)
el2 = set(h)

print(el1 is el2)
False
  • object/identify

class Test:
  test = 5

  def init(self, test):
    self.test = test

obj = Test(5)

print(Test.test is obj.test)
TypeError: Test() takes no arguments
  • object/identify

mylist1 = [[],[-1]]
mylist2 = [[],[-1]]
mylist2.sort()
print(mylist1 is mylist2)
False
  • object/identify
  • list/operation/append

L = [[1, 2, [3, 4]], [[3, 4, 5], [1, 2]]]
print(L[0] is L[1])
False
  • object/reference
  • object/identify