Python တွင် tuple အတွင်း element ရှိမရှိစစ်ဆေးခြင်း

List ထဲမှာ element တစ်ခုရှိမရှိကို operator in ကိုသုံးပြီးစစ်ဆေးနိုင်ပါတယ်။

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

print(res) # ရလဒ်က True ကိုပြသမည်

Element မရှိကြောင်းစစ်ဆေးချင်ရင် operator not in ကိုသုံးရပါမယ်။

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

print(res) # ရလဒ်က False ကိုပြသမည်
Задание 1

Tuple တစ်ခုပေးထားပါတယ်။

pythontpl = (2, 4, 6, 10)

အဲဒီထဲမှာ 8 ဆိုတဲ့နံပါတ်ရှိမရှိစစ်ဆေးပါ။

Задание 2

Tuple တစ်ခုပေးထားပါတယ်။

pythontpl = ('abc', 'def')

အဲဒီထဲမှာ 'd' ဆိုတဲ့ string ရှိမရှိစစ်ဆေးပါ။

Задание 3

အောက်ပါ code ကိုပေးထားပါတယ်။

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

print(res)

Console မှာဘာထွက်လာမလဲပြောပြပါ။

Задание 4

အောက်ပါ code ကိုပေးထားပါတယ်။

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

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

Console မှာဘာထွက်လာမလဲပြောပြပါ။