01/10/2018, 01:02

Giải thích toán tử trong python

mọi người cho em hỏi ngu 1 chút. e chạy trong python>>> (-4<7<7) là false

(-4<4<7) là true
(-4>4<7) là false. e không hiểu cho lắm. thanks all

KYN viết 03:03 ngày 01/10/2018

nhớ ko nhầm thì : -4 > 4 = False mà đã False rồi thì làm j ở sau nữa cũng False, chi tiết thì đợi nhớ lại đã

KYN viết 03:03 ngày 01/10/2018

nhầm sang short-circuit operator :

en.wikipedia.org

Short-circuit evaluation

Short-circuit evaluation, minimal evaluation, or McCarthy evaluation (after John McCarthy) is the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression: when the first argument of the AND function evaluates to false, the overall value must be false; and when the first argument of the OR function evaluates to true, the overall value must be true. I...


https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not

xem phần 4.3 :
x < y <= z is equivalent to x < y and y <= z
thế này mới đúng

Been viết 03:08 ngày 01/10/2018

thanks bro nhé.

Lê Nguyễn Anh Khoa viết 03:09 ngày 01/10/2018

Thanks bro nhiều. Học python bữa giờ thấy câu này cũng ngây người ra

Bài liên quan
0