Không phải toán tử Python

Từ khóa Python not là một toán tử logic thường được sử dụng để tìm ra giá trị boolean phủ định hoặc ngược lại của toán hạng. Từ khóa 'không' là một toán tử kiểu đơn nguyên, có nghĩa là nó chỉ nhận một toán hạng cho phép toán logic và trả về phần bù của giá trị boolean của toán hạng. Ví dụ: nếu chúng ta đặt false làm toán hạng cho từ khóa not thì chúng ta sẽ nhận được giá trị trả về là true.  

cú pháp. không phải var

Ứng dụng thực tế

Ứng dụng thực tế có thể có của từ khóa not là.  

  • Từ khóa này chủ yếu được sử dụng để thay đổi giá trị boolean
  • Nó được sử dụng với câu lệnh if. Trong câu lệnh if Nó được sử dụng để phủ định điều kiện
  • từ khóa 'không' cũng được sử dụng với từ khóa. Nó được sử dụng với từ khóa in khi chúng tôi đang tìm kiếm giá trị cụ thể trong bộ sưu tập dữ liệu

ví dụ 1. Ví dụ cơ bản về toán tử not với biến true

Python3




True
00

True
01
True
02
True
03

True
04
True
0
True
1
True
2

đầu ra

False

ví dụ 2. Ví dụ cơ bản về toán tử không có biến

Python3




True
00

True
01____202
True
6

True
04
True
0
True
1
True
2

đầu ra

True

ví dụ 3. Ví dụ với điều kiện cụ thể

Vì thuộc tính cơ bản của từ khóa 'không' là nó được sử dụng để đảo ngược giá trị thực của toán hạng. Vì vậy, chúng ta có thể thấy ở đây rằng kết quả của mọi giá trị được đảo ngược từ giá trị thực của chúng. Tại #5, chúng ta có thể thấy kết quả của thao tác so sánh sẽ là sai, do đó, phủ định nó, chúng ta nhận được giá trị True. Tương tự, chúng ta có thể thấy tất cả các kết quả đều bị đảo ngược

Python3




Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
1

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
2

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
3

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
4
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
5

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
6

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
8

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
80
True
02
True
1
True
6

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
87
True
88

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
60

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
62____202
True
1
True
03

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
69
True
000

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
002

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
004
True
02
True
1
True
0
True
03
True
009
True
6
True
011

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
015
True
016

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7____2018

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
020
True
02
True
1
True
0
True
03
True
025
True
6
True
011

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
031
True
032

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
034

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
036
True
02
True
1
True
0
True
040
True
041
True
042
True
011

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
015
True
048

 

 

True
049

đầu ra.  

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True

Ví dụ 4. Trong Mã này, chúng tôi chỉ ra hoạt động của toán tử 'không' với một giá trị khác với giá trị boolean và xem nó hoạt động như thế nào.  

Python3




Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
1

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
2

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
3

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
4
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
5

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
6

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
07

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
09
True
02
True
11

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
15
True
16
True
1
True
18

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
20

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
22
True
02
True
24
True
25
True
16
True
27
True
16
True
29
True
16
True
31
True
32

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
36
True
16
True
1
True
39

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
41

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
43
True
02
True
45
True
11
True
47
True
48
True
16
True
50
True
47
True
52
True
53

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
57
True
16
True
1
True
60

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
62

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
64
True
02
True
66

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
70
True
16
True
1
True
73

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
75

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
77____202
True
79

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
83
True
16
True
1
True
86

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
88

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7____090____202
True
92

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
True
04
True
0
True
96
True
16
True
1
True
99

 

True
049

đầu ra.  

True
8

Trong ví dụ trên, chúng ta đã thấy rằng việc coi tất cả các kiểu dữ liệu là toán hạng không có từ khóa. , 'không' xử lý đúng với tất cả các loại dữ liệu có giá trị và sai đối với những loại có giá trị trống

Ví dụ 5. Ví dụ với danh sách

Python3




Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
1

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
2

 

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
03
True
02
True
24_______2040
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
08
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
10
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
12
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
14
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
16
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
18
True
32

 

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
3

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
4
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
5

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
6

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
25

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
7
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
27
True
1
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
29

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
30
True
04
True
0
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
33
True
011

_______97____936____047

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
30
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
39
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
40
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
41
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
29

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
43______927
True
1____946
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
47
True
040
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
49

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
50

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
51
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
52

Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
51
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
27
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
40
True
1
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
41
True
0
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
59
True
16
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
08
Negation  of False :  True
Negation of True :  False
Negation of result of And operation :  True
Negation of result of or operation :  False
Negation of result of And operation :  True
49

không phải hoặc. = Bằng Python?

Bằng Python . = được định nghĩa là không bằng toán tử . Nó trả về True nếu toán hạng ở hai bên không bằng nhau và trả về False nếu chúng bằng nhau. Trong khi đó, toán tử không kiểm tra xem id[] của hai đối tượng có giống nhau hay không.

Điều gì không phải là nhà điều hành?

Toán tử NOT có nghĩa là gì? . Về cơ bản, toán tử đảo ngược giá trị logic được liên kết với biểu thức mà nó hoạt động. a Boolean operator that returns TRUE or 1 when the operand is FALSE or 0, and returns FALSE or 0 when the operand is TRUE or 1. Essentially, the operator reverses the logical value associated with the expression on which it operates.

Biểu tượng không có trong Python là gì?

Sự miêu tả

Chủ Đề