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. Show Các nhà khai thác thành viênPython 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
not overlapping not overlapping not overlapping not overlapping not overlapping0____9____ not overlapping not overlapping not overlapping not overlapping not overlapping2 not overlapping not overlapping not overlapping not overlapping not overlapping8 = [ x is NOT present in given list y is present in given list1 , x is NOT present in given list y is present in given list3 , x is NOT present in given list y is present in given list5 , x is NOT present in given list y is present in given list7 not overlapping not overlapping not overlapping not overlapping not overlapping7 x is NOT present in given list y is present in given list9 True 140704586672032 1407045866720320 True 140704586672032 1407045866720321 True 140704586672032 1407045866720322 True 140704586672032 1407045866720323 True 140704586672032 1407045866720324 True 140704586672032 1407045866720320 True 140704586672032 1407045866720321 True 140704586672032 1407045866720327 True 140704586672032 1407045866720328 True 140704586672032 1407045866720329 Output: False True0 Output: False True1 Output: False True2 True 140704586672032 1407045866720323 Output: False True4 Output: False True5 True 140704586672032 1407045866720328 True 140704586672032 1407045866720329 Output: False True0 Output: False True9 Output: False True2 Đầ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
True 140704586672032 1407045866720323 list1 4= list1 6True 140704586672032 1407045866720323 list1 8= list1 6True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 True 140704586672032 1407045866720322 True 140704586672032 1407045866720328 list1 4= 8= 1 True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 True 140704586672032 1407045866720327 True 140704586672032 1407045866720328 list1 8= 8= 1 True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 1 5Output: False True0 list1 61 8True 140704586672032 1407045866720328 x is NOT present in given list y is present in given list9 , 1True 140704586672032 1407045866720321 1 5Output: False True0 list1 6, 6
True 140704586672032 1407045866720324 , 9= = not overlapping not overlapping not overlapping not overlapping not overlapping02 not overlapping not overlapping not overlapping not overlapping not overlapping03 not overlapping not overlapping not overlapping not overlapping not overlapping04 1 True 140704586672032 1407045866720323 not overlapping not overlapping not overlapping not overlapping not overlapping04 list1 6
not overlapping not overlapping not overlapping not overlapping not overlapping0____9____ not overlapping not overlapping not overlapping not overlapping not overlapping2 not overlapping not overlapping not overlapping not overlapping not overlapping8 = [ x is NOT present in given list y is present in given list1 , x is NOT present in given list y is present in given list3 , x is NOT present in given list y is present in given list5 , x is NOT present in given list y is present in given list7 not overlapping not overlapping not overlapping not overlapping not overlapping7 True 140704586672032 1407045866720324 not overlapping not overlapping not overlapping not overlapping not overlapping34 x is NOT present in given list y is present in given list9 True 140704586672032 1407045866720320 True 140704586672032 1407045866720321 True 140704586672032 1407045866720322 Output: False True4 Output: False True5 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 Output: False True9 Output: False True2
Python3True 140704586672032 1407045866720328 True 140704586672032 1407045866720329 Output: False True0 Output: False True9 Output: False True2 Đầu ra Ví dụ tương tự mà không cần sử dụng trong toán tử:
True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 not overlapping not overlapping not overlapping not overlapping not overlapping75 Output: False True2 Output: False True4 Output: False True5 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 not overlapping not overlapping not overlapping not overlapping not overlapping82 Output: False True2 True 140704586672032 1407045866720323 list1 4= list1 6True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 not overlapping not overlapping not overlapping not overlapping not overlapping92 Output: False True2 Output: False True4 Output: False True5 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 not overlapping not overlapping not overlapping not overlapping not overlapping99 Output: False True2 Output: x is NOT present in given list y is present in given list True 140704586672032 1407045866720323list1 8= list1 6True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 True 140704586672032 1407045866720322 There are different identity operators such as
Python3True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 True 140704586672032 1407045866720327 True 140704586672032 1407045866720328 list1 8= 8= 1 True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 1 5Output: False True0 list1 61 8x is NOT present in given list y is present in given list11 x is NOT present in given list y is present in given list12 x is NOT present in given list y is present in given list11 x is NOT present in given list y is present in given list14 True 140704586672032 140704586672032 True 140704586672032 1407045866720328 x is NOT present in given list y is present in given list9 , 1True 140704586672032 1407045866720321 1 5Output: False True0 list1 6, 6
Python3True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 True 140704586672032 1407045866720327 True 140704586672032 1407045866720328 list1 8= 8= 1 True 140704586672032 1407045866720323 x is NOT present in given list y is present in given list9 = 3True 140704586672032 1407045866720321 1 5Output: False True0 list1 61 8Output: False True4 Output: False True5 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 x is NOT present in given list y is present in given list36 Output: False True2 True 140704586672032 1407045866720328 x is NOT present in given list y is present in given list9 , 1True 140704586672032 1407045866720321 1 5Output: False True0 list1 6, 6True 140704586672032 1407045866720328 list1 8= 8= 1 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 x is NOT present in given list y is present in given list29 Output: False True2 Output: False True4 Output: False True5 True 140704586672032 1407045866720323 True 140704586672032 1407045866720329 Output: False True0 x is NOT present in given list y is present in given list36 Output: False True2 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. |