【发布时间】:2016-12-18 13:03:46
【问题描述】:
if op in ["/"]:
# rounding does not rounds half up so I imported a module
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN
Decimal(str(answer)).quantize(Decimal("1.11"), rounding=ROUND_HALF_UP)
Decimal(str(given_answer)).quantize(Decimal("1.11"), rounding=ROUND_HALF_UP)
print("correct {}".format(answer, ".2f"))
49//34=?1.44
正确 1
回答错误!
如果真正的答案是 3.55865465,我希望它的正确答案是 3.56。我做错了什么?
【问题讨论】:
-
49/34 是 1.44 为什么你希望它是
3.56?正确的答案是什么? -
我并不是说我想要 49/34 的 3.56。 “如果真正的答案是 3.55865465,我希望它的正确答案是 3.56。”
标签: python python-3.x counter division rounding-error