Python Programming - Tricky Questions - Discussion

Discussion Forum : Tricky Questions - General Questions (Q.No. 20)
20.
What will be the output of the following Python code?
x = 0.1
y = 0.2
result = x + y
print(result)
0.3
0.30000000000000004
0.2
This code will result in an error.
Answer: Option
Explanation:
Floating-point arithmetic may result in small precision errors, and the actual result is approximately 0.30000000000000004.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.