>>> a=3
>>> a+2.0
5.0
>>> a=a+1.0
>>> a
4.0
Can't understand why 4.0 is coming. I think 6.0 should be the answer. Please explain why the result is 4.0.
On the second line when you do a+2.0, you are not modifying the value of a, so on the third line a is still 3 and a+1.0 is 4.0 as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With