How is this expression evaluated false in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How is this expression evaluated false in python?

a = 9 ** 19 == int(float(9 ** 19)) print(a) How is value of a is false. Plz help

20th Sep 2019, 1:55 PM
Devarsh Mavani
Devarsh Mavani - avatar
1 Answer
+ 4
The two numbers 9 ** 19 and int(float(9 ** 19)) apparently are two different values. I presume this was due to the conversion to int from float, which reduces/changes the precision of the decimal point. You can easily verify this by printing the two values as follows: print(9 ** 19, int(float(9 ** 19))) There you'll see they are different, and as such checking them for equality yields false, which then be stored into variable <a>. Hth, cmiiw
20th Sep 2019, 2:04 PM
Ipang