Free webinar! How to Make Generative AI Work for You
Get my free ticket+ 10
Python intepret the expression as
Print((1<2)and(2>1)) which both evaluate to true...
To get false as you may have expected use parentheses to implicitly take control in order of precedence, remember those are binary operator so you will just group the first or last two operands e.g
Print((1<2)>1) or print(1<(2>1)) both are the same Expression
+ 4
Python has a different feature!
In python:
(1<2>1)
Means 1 < 2 and 2 > 1
So it outputs true
But if you try the same in js
You ll be shocked!
It's false!
In js:
1 < 2 => true = 1
1 > 1 = false
+ 3
In python
1<2 is true &
2>1 is also true so the combine statement is true..
+ 2
Expression is evaluated from left to right one operator at a time....
+ 1
1<2 is the same as 2>1 True and True = True
+ 1
python intepret expressed it 1 is smaller than 2 then 2 is bigger than 1 as you have put greater than and smaller than sign
0
print((1>2)and(2>1))
- 1
🚩🚩🚩🚩🚩🚩🚩 it's maths concept 😅better to learn maths first before coding
- 2
Agree with u Loma 😅