Elemento buvimas tuple sąraše Python kalba

Sužinoti ar tam tikras elementas yra sąraše galima naudojant operatorių in:

pythontpl = ('a', 'b' 'c')
res = 'a' in tpl

print(res) # išves True

Norint patikrinti elemento nebuvimą, reikia naudoti operatorių not in:

pythontpl = ('a', 'b' 'c')
res = 'a' not in tpl

print(res) # išves False
Задание 1

Duotas tuple:

pythontpl = (2, 4, 6, 10)

Patikrinkite, ar jame yra skaičius 8.

Задание 2

Duotas tuple:

pythontpl = ('abc', 'def')

Patikrinkite, ar jame yra eilutė 'd'.

Задание 3

Duotas toks kodas:

pythontpl = ('1', '2', '3')
res = 1 not in tpl

print(res)

Pasakykite, kas bus išvesta į konsolę.

Задание 4

Duotas toks kodas:

pythontpl1 = ('ac', '3', 4, 'bd', 5)
tpl2 = (1, 2, 3)

res1 = 4 in tpl1
res2 = 2 not in tpl2
print(res1)
print(res2)

Pasakykite, kas bus išvesta į konsolę.