Quiz Catalog

Catalog of quizzes

a = ()

print(type(a))
<class 'tuple'>
  • tuple/literal

list_of_tuple = [('bob', 35, 'mgr'), ('sue', 40, 'dev')]

data = list(map((lambda row: row[2]), list_of_tuple))

print(data)
['mgr', 'dev']
  • build-in/map
  • build-in/list
  • list/literal
  • tuple/literal
  • lambda

tuple1 = (1, 2, 3)
tuple2 = tuple(1, 2, 3)

print(tuple1 == tuple2)
TypeError: tuple expected at most 1 argument, got 3
  • tuple/literal
  • build-in/tuple

lst = [(2, 3), (2, 9), (5, 0)]

a = dict(lst)

print(a)
{2: 9, 5: 0}
  • build-in/dict
  • build-in/int
  • list/literal
  • tuple/literal

def foo(value):
  t = value,
  return t

print(foo(1))
(1,)
  • tuple/literal

t1 = (11, 14, 54, 0, 58, 41)
res = len(set(t1)) == len(t1)

print(res)
True
  • tuple/literal
  • set/parameter

value = (4, 5, 6)

print(type(value) is tuple)
True
  • tuple/literal
  • type

tpl = (4, 1, 0, 'a')

a = any(tpl)

print(a)
True
  • build-in/any
  • tuple/literal
  • boolean

str = 'abc'
num = (10, 20, 30, 40)

a = list(zip(str, num))

print(a)
[('a', 10), ('b', 20), ('c', 30)]
  • build-in/zip
  • build-in/list
  • tuple/literal

first, second = zip(*[(1, 4), (2, 5), (3, 6)])

print(first, second)
(1, 2, 3) (4, 5, 6)
  • build-in/zip
  • list/literal
  • tuple/literal

vowels = ('a', 'e', 'i', 'o', 'u')

fSet = frozenset(vowels)

fSet.add('v')
AttributeError: 'frozenset' object has no attribute 'add'
  • build-in/frozenset
  • tuple/literal