+ 1
1==1.0 output True
Why print(1==1.0) output True? The former is int and the latter is float
2 Respuestas
+ 1
When you compare values of 2 data types, the interpreter will automatically turn them into 1 type. So the output will always be true.
But on languages like java, js, (and maybe c langs) they use === , equality and type checking
+ 1
On a deeper level, it depends on how the types, specifically their comparison tools, are designed.
You can't just compare everything in Python, very often you'll get a TypeError when you try.
But for int and float, one cross-class comparison is defined, I guess for convenience.