Quiz Catalog

Catalog of quizzes

num_list: list = [1, 3, 6, 10]
multiplied_list = (num**2 for num in num_list)

print(type(multiplied_list))
<class 'generator'>
  • generator
  • build-in/list
  • build-in/type

numbers = [1, 2, 3, 4, 5]
squares: list = [number**2 for number in numbers if number % 2 == 0]

print(squares)
[4, 16]
  • generator
  • build-in/list

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

lst = [4.6, 2.3, 7.8]
a = list([2, 5.9])

for num in lst:
  a.append(int(num))

print(a)
[2, 5.9, 4, 2, 7]
  • build-in/int
  • build-in/list
  • list/operation/append

lst = [-4, 0, 2, '', 7, 'a', ' ', -4]

b = list(filter(None, lst))

print(b)
[-4, 2, 7, 'a', ' ', -4]
  • build-in/filter
  • build-in/list
  • list/literal

def check(x):
  if x % 2 == 0:
    return 1


lst = [2, 1, 4, 5, 3]

a = list(filter(check, lst))

print(a)
[2, 4]
  • build-in/filter
  • build-in/list
  • expression/operation/modulo
  • list/literal

print(list(range(2, 15, 3)))
[2, 5, 8, 11, 14]
  • build-in/range
  • build-in/list

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

data = ['bread', 'milk', 'butter']

enumerate_num = enumerate(data, 1)

print(list(enumerate_num))
Roma
  • build-in/enumerate
  • build-in/list
  • list/literal