1.

What is the output of print 0.1 + 0.2 == 0.3?(a) True(b) False(c) Machine dependent(d) ErrorThe question was asked by my school teacher while I was bunking the class.I want to ask this question from Numeric Types in portion Variable Names, Operators, Data Types & Numeric Types of Python

Answer»

The correct ANSWER is (b) False

Best explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The ROUND off ERRORS from 0.1 and 0.2 accumulate and hence there is a DIFFERENCE of 5.5511e-17 between (0.1 + 0.2) and 0.3.



Discussion

No Comment Found

Related InterviewSolutions