Hướng dẫn program for membership operator in python - chương trình cho nhà điều hành thành viên trong python

Trong bài viết này, chúng tôi sẽ học các nhà khai thác thành viên và nhận dạng Python.

Các nhà khai thác thành viên

Python cung cấp hai nhà khai thác thành viên để kiểm tra hoặc xác thực thành viên của một giá trị. Nó kiểm tra tư cách thành viên trong một chuỗi, chẳng hạn như chuỗi, danh sách hoặc bộ dữ liệu. & Nbsp;

Trong toán tử: Toán tử ’trong toán tử được sử dụng để kiểm tra xem một ký tự/ chuỗi con/ phần tử có tồn tại theo trình tự hay không. Đánh giá đúng nếu nó tìm thấy phần tử được chỉ định trong một chuỗi khác là sai. Ví dụ,The ‘in’ operator is used to check if a character/ substring/ element exists in a sequence or not. Evaluate to True if it finds the specified element in a sequence otherwise False. For example,

'G' in 'GeeksforGeeks'   # Checking 'G' in String
True
'g' in 'GeeksforGeeks'   #Checking 'g' in string since Python is case-sensitive,returns False
False
'Geeks' in ['Geeks', 'For','Geeks']   #Checking 'Geeks' in list of strings
True
10 in [10000,1000,100,10]        #Checking 10 in list of integers
True
dict1={1:'Geeks',2:'For',3:'Geeks'}     # Checking 3 in keys of dictionary
3 in dict1
True

Python3

list1 = [1,

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
0____9____
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
2

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
8= [
x is NOT present in given list
y is present in given list
1,
x is NOT present in given list
y is present in given list
3,
x is NOT present in given list
y is present in given list
5,
x is NOT present in given list
y is present in given list
7
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
7

x is NOT present in given list
y is present in given list
9
True
140704586672032
140704586672032
0
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
2

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
4
True
140704586672032
140704586672032
0
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
7

True
140704586672032
140704586672032
8
True
140704586672032
140704586672032
9
Output:
False
True
0
Output:
False
True
1
Output:
False
True
2

True
140704586672032
140704586672032
3
Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
8
True
140704586672032
140704586672032
9
Output:
False
True
0
Output:
False
True
9
Output:
False
True
2

Đầu ra

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping

Ví dụ tương tự mà không cần sử dụng trong toán tử:

Python3

list1 1 list1 2

True
140704586672032
140704586672032
3list1 4= list1 6

True
140704586672032
140704586672032
3list1 8= list1 6

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
2

True
140704586672032
140704586672032
8list1 4=8= 1

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
7

True
140704586672032
140704586672032
8list1 8=8= 1

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 618

True
140704586672032
140704586672032
8
x is NOT present in given list
y is present in given list
9 , 1
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 6, 6

, 7

True
140704586672032
140704586672032
4, 9==
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
02

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
03
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
04 1

True
140704586672032
140704586672032
3
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
04 list1 6

list1 = [1,

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
0____9____
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
2

not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
8= [
x is NOT present in given list
y is present in given list
1,
x is NOT present in given list
y is present in given list
3,
x is NOT present in given list
y is present in given list
5,
x is NOT present in given list
y is present in given list
7
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
7

True
140704586672032
140704586672032
4
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
34

x is NOT present in given list
y is present in given list
9
True
140704586672032
140704586672032
0
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
2

Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
Output:
False
True
9
Output:
False
True
2

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
4
True
140704586672032
140704586672032
0
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
7
Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.

Python3

True
140704586672032
140704586672032
8
True
140704586672032
140704586672032
9
Output:
False
True
0
Output:
False
True
9
Output:
False
True
2

Đầu ra

Ví dụ tương tự mà không cần sử dụng trong toán tử:

list1 1 list1 2

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
75
Output:
False
True
2

Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
82
Output:
False
True
2

True
140704586672032
140704586672032
3list1 4= list1 6

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
92
Output:
False
True
2

Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
99
Output:
False
True
2

Output:

x is NOT present in given list
y is present in given list

True 140704586672032 1407045866720323list1 8= list1 6

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
2
There are different identity operators such as 

True
140704586672032
140704586672032
8list1 4=8= 1 Evaluates to True if the variables on either side of the operator point to the same object and false otherwise.

Python3

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
7

True
140704586672032
140704586672032
8list1 8=8= 1

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 618

x is NOT present in given list
y is present in given list
11
x is NOT present in given list
y is present in given list
12

x is NOT present in given list
y is present in given list
11
x is NOT present in given list
y is present in given list
14

True
140704586672032
140704586672032

True
140704586672032
140704586672032
8
x is NOT present in given list
y is present in given list
9 , 1
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 6, 6

, 7

True
140704586672032
140704586672032
4, 9==
not overlapping
not overlapping
not overlapping
not overlapping
not overlapping
02
Evaluates to true if the variables on either side of the operator point to a different object and true otherwise.

Python3

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1
True
140704586672032
140704586672032
7

True
140704586672032
140704586672032
8list1 8=8= 1

True
140704586672032
140704586672032
3
x is NOT present in given list
y is present in given list
9 =3
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 618

Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
x is NOT present in given list
y is present in given list
36
Output:
False
True
2

True
140704586672032
140704586672032
8
x is NOT present in given list
y is present in given list
9 , 1
True
140704586672032
140704586672032
1 15
Output:
False
True
0list1 6, 6

True
140704586672032
140704586672032
8list1 8=8= 1

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
x is NOT present in given list
y is present in given list
29
Output:
False
True
2

Output:
False
True
4
Output:
False
True
5

True
140704586672032
140704586672032
3
True
140704586672032
140704586672032
9
Output:
False
True
0
x is NOT present in given list
y is present in given list
36
Output:
False
True
2

Output:
False
True

Nhà điều hành thành viên trong ví dụ Python là gì?

Các nhà khai thác thành viên Python.

Nhà điều hành thành viên với ví dụ là gì?

Chúng tôi sử dụng các toán tử thành viên để kiểm tra xem một giá trị hoặc biến có tồn tại trong một chuỗi (chuỗi, danh sách, bộ dữ liệu, bộ, từ điển) hay không.x = "Xin chào, thế giới!"x = "Xin chào, thế giới!"x = "Xin chào, thế giới!"to check whether a value or variable exists in a sequence (string, list, tuples, sets, dictionary) or not. x = "Hello, World!" x = "Hello, World!" x = "Hello, World!"

Những người vận hành thành viên của chuỗi trong Python là gì?

Trong Python, có hai nhà khai thác thành viên.(trong, không phải trong).Nó hiển thị kết quả trong chuỗi hoặc chuỗi đã cho tập trung vào biến hiện tại.(in, not in). It displays the result in the given sequence or string centred on the present variable.

Chức năng của nhà điều hành thành viên trong Python là gì?

Các nhà khai thác thành viên là các nhà khai thác được sử dụng để xác nhận tư cách thành viên của một giá trị.Nó kiểm tra tư cách thành viên trong một chuỗi, chẳng hạn như chuỗi, danh sách hoặc bộ dữ liệu.Trong toán tử: toán tử 'In' được sử dụng để kiểm tra xem giá trị có tồn tại theo trình tự hay không.to validate the membership of a value. It test for membership in a sequence, such as strings, lists, or tuples. in operator : The 'in' operator is used to check if a value exists in a sequence or not.