W3Schools được tối ưu hóa cho việc học và đào tạo. Ví dụ có thể được đơn giản hóa để cải thiện việc đọc và học tập. Hướng dẫn, tài liệu tham khảo và ví dụ được xem xét liên tục để tránh lỗi, nhưng chúng tôi không thể đảm bảo tính chính xác đầy đủ của tất cả các nội dung. Trong khi sử dụng W3Schools, bạn đồng ý đã đọc và chấp nhận các điều khoản sử dụng, cookie và chính sách bảo mật của chúng tôi.
Bản quyền 1999-2022 bởi dữ liệu refsnes. Đã đăng ký Bản quyền. W3Schools được cung cấp bởi W3.CSS.
W3Schools is Powered by W3.CSS.
Các toán tử được sử dụng để thực hiện các hoạt động trên các giá trị và biến. Đây là những biểu tượng đặc biệt thực hiện các tính toán số học và logic. Giá trị mà người vận hành hoạt động được gọi là toán hạng.Operand.
Mục lục
- Toán tử logic
- Logic và toán tử
- Logic hoặc toán tử
- Logic không vận hành
- Thứ tự đánh giá các toán tử logic
Toán tử logic
Logic và toán tửLogical AND, Logical OR and Logical NOT operations.
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic. | NHÀ ĐIỀU HÀNH | SỰ MÔ TẢ |
Cú pháp | và | Logic và: true nếu cả hai toán hạng là đúng |
x và y | hoặc | Logic hoặc: true nếu một trong hai toán hạng là đúng |
Logic và toán tử
Logic hoặc toán tử
Logic không vận hành
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
NHÀ ĐIỀU HÀNH
SỰ MÔ TẢ
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Either of the number is greater than 0 No number is greater than 08
Either of the number is greater than 0 No number is greater than 09
Cú pháp
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Either of the number is greater than 0 No number is greater than 08
Either of the number is greater than 0 No number is greater than 09
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Method called for value: -1 Method called for value: 5 Atleast one of the number is positive0
Either of the number is greater than 0 No number is greater than 09
Output:
The numbers are greater than 0 Atleast one number is not greater than 0
và
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
NHÀ ĐIỀU HÀNH
SỰ MÔ TẢ
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
False
0Either of the number is greater than 0 No number is greater than 09
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
False
7Either of the number is greater than 0 No number is greater than 09
Output:
Atleast one number has boolean value as False
Cú pháp If the first expression evaluated to be false while using and operator, then the further expressions are not evaluated.
và
Logic và: true nếu cả hai toán hạng là đúng
Logic không vận hành
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
NHÀ ĐIỀU HÀNH
SỰ MÔ TẢ
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
=
9Either of the number is greater than 0 No number is greater than 09
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Cú pháp
và
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
=
9Either of the number is greater than 0 No number is greater than 09
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Atleast one number has boolean value as False06
Either of the number is greater than 0 No number is greater than 09
Output:
Either of the number is greater than 0 No number is greater than 0
Logic và: true nếu cả hai toán hạng là đúng
Example #2:
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
NHÀ ĐIỀU HÀNH
SỰ MÔ TẢ
Cú pháp
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Atleast one number has boolean value as False52
Either of the number is greater than 0 No number is greater than 09
Output:
Atleast one number has boolean value as True
và If the first expression evaluated to be True while using or operator, then the further expressions are not evaluated.
Logic và: true nếu cả hai toán hạng là đúng
x và y
Example:
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Atleast one number has boolean value as False65
Either of the number is greater than 0 No number is greater than 09
NHÀ ĐIỀU HÀNH
SỰ MÔ TẢ
10 is divisible by either 3 or 55
Either of the number is greater than 0 No number is greater than 04
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Atleast one number has boolean value as False93
Either of the number is greater than 0 No number is greater than 09
Output:
10 is divisible by either 3 or 5
Thứ tự đánh giá các toán tử logic
Trong Python, các toán tử logic được sử dụng trên các câu lệnh có điều kiện [đúng hoặc sai]. Họ thực hiện các hoạt động logic và logic hoặc logic hoặc logic.
Example:
Atleast one number has boolean value as False95
Atleast one number has boolean value as False96
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Either of the number is greater than 0 No number is greater than 000
Either of the number is greater than 0 No number is greater than 001
Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 003
Either of the number is greater than 0 No number is greater than 004
Atleast one number has boolean value as False8
Either of the number is greater than 0 No number is greater than 006
Either of the number is greater than 0 No number is greater than 00
10 is divisible by either 3 or 55
False
a
=
Either of the number is greater than 0 No number is greater than 012
Atleast one number has boolean value as False1
=
Either of the number is greater than 0 No number is greater than 012
Atleast one number has boolean value as False4
=
Either of the number is greater than 0 No number is greater than 012
Atleast one number has boolean value as False8
Either of the number is greater than 0 No number is greater than 020
Atleast one number has boolean value as False6
Either of the number is greater than 0 No number is greater than 02222223
=
2Either of the number is greater than 0 No number is greater than 05
Either of the number is greater than 0 No number is greater than 06
Either of the number is greater than 0 No number is greater than 07
Either of the number is greater than 0 No number is greater than 035
Either of the number is greater than 0 No number is greater than 09
Output:
Method called for value: -1 Method called for value: 5 Atleast one of the number is positive