0

Can we compare two data types such as an integer and a float and what Boolean value will I get?

13th Jan 2022, 5:31 AM
Velpuri Venkata Veera Anjaneyulu
Velpuri Venkata Veera Anjaneyulu - avatar
2 Answers
+ 7
In Python? Yes! print(3.6 > 3) -> True print(5.4 > 6) -> False print(6.0 == 6) -> True
13th Jan 2022, 5:45 AM
Simba
Simba - avatar
+ 1
You probably can, if the `float` variable only has zero past decimal separator. I don't think it's a good idea otherwise. Why you wanna compare integer to a floating point type though? they are different by nature.
13th Jan 2022, 5:48 AM
Ipang