0

Why is 2.0==2 True even though 2.0 is float and 2 is int?

print(2.0==2)

output:

True
alex
  • 10,900
  • 15
  • 70
  • 100

1 Answers1

0

Well, 2.0 is just a decimal representation of 2, so 2.0 = 2. If, however, we are dealing with strings, then '2.0' != '2'. I hope that helps.

MathGeek
  • 141
  • 9