Prania e një elementi në tuple në Python

Nëse një element i caktuar është në listë mund të kontrollohet duke përdorur operatorin in:

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

print(res) # do të shfaqë True

Për të kontrolluar mungesën e një elementi, duhet përdorur operatorët not in:

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

print(res) # do të shfaqë False
Задание 1

Jepet tuple:

pythontpl = (2, 4, 6, 10)

Kontrolloni nëse numri 8 gjendet në të.

Задание 2

Jepet tuple:

pythontpl = ('abc', 'def')

Kontrolloni nëse vargu 'd' gjendet në të.

Задание 3

Jepet kodi në vijim:

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

print(res)

Thuani çfarë do të shfaqet në konsolë.

Задание 4

Jepet kodi në vijim:

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

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

Thuani çfarë do të shfaqet në konsolë.