Provera prisustva elementa u tuple u Pythonu

Možemo saznati da li određeni element postoji u listi koristeći operator in:

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

print(res) # ispisaće True

Da biste proverili odsustvo elementa, treba da koristite operatore not in:

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

print(res) # ispisaće False
Задание 1

Dat je tuple:

pythontpl = (2, 4, 6, 10)

Proverite da li u njemu postoji broj 8.

Задание 2

Dat je tuple:

pythontpl = ('abc', 'def')

Proverite da li u njemu postoji string 'd'.

Задание 3

Dat je sledeći kod:

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

print(res)

Recite šta će biti ispisano u konzolu.

Задание 4

Dat je sledeći kod:

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

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

Recite šta će biti ispisano u konzolu.