0

a = 2 + float("3") b = 5 c = a == b print(c) why is python silently converting 'b' into a float 5.0 in comparison '==' operatn

Python boolean

26th Mar 2018, 9:24 PM
PyDiv()
PyDiv() - avatar
2 Respostas
+ 2
because a is a float
26th Mar 2018, 9:41 PM
Skipper
Skipper - avatar
+ 2
Python coerces the int into a float to perform the addition, then returns a float as the result.
26th Mar 2018, 9:44 PM
Damyan Petkov
Damyan Petkov - avatar