# %%

# def f(x):
#   return x**2

# f = lambda x : x **2

print(list(map(lambda x : x **2,range(1,10))))


# %%

l = ['hi,', 'i', 'am', 'alice']

# print(str.upper(l[0]))
l2 = []
for x in l:
    l2.append(str.upper(x))

# print(l2)
# print(list(map(str.upper,l)))
print([str.upper(x) for x in l])

# %%

def is_even(n):
    return (n%2) == 0

# for i in filter(is_even, range(0,51)):
#     print(i)
print(list(filter(is_even, range(0,51))))
# print([x for x in range(0,51) if is_even(x)])

# %%

list_strings = ['slug', 'tiger', 'cat', 'fox', 'eagle']

def is_length_small_three(x):
    return len(x) <= 3

print((lambda x : len(x) <= 3)("aze"))
print((lambda x : len(x) <= 3)("arzzerr"))

# print([x for x in list_strings if len(x) <= 3])
# print(list(filter(is_length_small_three, list_strings)))
print(list(filter(lambda x : len(x) <= 3, list_strings)))

# %%

l = [0, -1, 21, -4, 10, 1]
print(all(map(lambda x : x >=0, l)))

# %%

def dic_from_lists(l1, l2):
    res = {}
    for x, y in zip(l1, l2):
        res[x] = y
    return res

print(dic_from_lists(['name', 'first name', 'company'],['Freeman', 'Gordon', 'Black Mesa']))

# %%
def sum_pair(l1, l2):
    new_l = []
    for (x1, x2) in zip(l1,l2):
        x = x1+x2
        new_l.append(x !=0 and x % 2 == 0)
    return all(new_l)

print(sum_pair([10,8,1,0,4], [2,-8,2,1,4]))

print(all(map(lambda x : x[0]+x[1] !=0 and (x[0]+x[1]) % 2 == 0,
          zip([10,8,1,0,4], [2,-8,2,1,4]))))
# %%
