Python Programming - Tricky Questions - Discussion

Discussion Forum : Tricky Questions - General Questions (Q.No. 17)
17.
What is the output of the following Python code?
result = 1.0 - 0.1 - 0.1 - 0.1 - 0.1 - 0.1
print(result)
0.5000000000000001
0.6
0.4
0.0
Answer: Option
Explanation:
Floating-point arithmetic may result in small precision errors, and the actual result is approximately 0.5.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.