HOW TO MULTIPLY THREE DECIMAL NUMBERS IN PYTHON?
PLS TELL THE CODE
I WILL GIVE U SO MUCH POINTS
Answers
Answered by
2
Answer:
>>> 100*.56
56.00000000000001
>>> Decimal('100')*Decimal('.56')
Decimal('56.
- Explanation:
In Python 3 input will return a string. This is basically equivalent of raw_input in Python 2. So, you need to convert that string to a number before performing any calculation. And be prepared for "bad input" (i.e: non-numeric values).
In addition, for monetary values, it is usually not a good idea to use floats. You should use decimal to avoid rounding errors:
Similar questions