⊗pyPmTpEP 71 of 208 menu

Presence of element in tuple in Python

You can find out whether a given element is in the list using the in operator:

tpl = ('a', 'b' 'c') res = 'a' in tpl print(res) # True

To check for the absence of an element, you should use the not in operators:

tpl = ('a', 'b' 'c') res = 'a' not in tpl print(res) # False

A tuple is given:

tpl = (2, 4, 6, 10)

Check if it contains the number 8.

A tuple is given:

tpl = ('abc', 'def')

Check if it contains the string 'd'.

The following code is given:

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

Tell me what will be output to the console.

The following code is given:

tpl1 = ('ac', '3', 4, 'bd', 5) tpl2 = (1, 2, 3) res1 = 4 in tpl1 res2 = 2 not in tpl2 print(res1) print(res2)

Tell me what will be output to the console.

byenru