The problem is default decimal rounding setting of ROUND_HALF_EVEN (on 5 round to closest even number).
>>> print '{:.2}'.format(decimal.Decimal('6.75')) 6.8
>>> average = decimal.Decimal('6.85')
>>> print '{:.1f}'.format(average) 6.8
>>> ctx = decimal.Context(rounding=decimal.ROUND_HALF_UP)
>>> with decimal.localcontext(ctx): print '{:.1f}'.format(average) ... 6.9
Read https://docs.python.org/2/library/decimal.html
The problem is default decimal rounding setting of ROUND_HALF_EVEN (on 5 round to closest even number).
>>> print '{:.2}' .format( decimal. Decimal( '6.75') )
6.8
>>> average = decimal. Decimal( '6.85')
>>> print '{:.1f} '.format( average)
6.8
>>> ctx = decimal. Context( rounding= decimal. ROUND_HALF_ UP)
>>> with decimal. localcontext( ctx): '.format( average)
print '{:.1f}
...
6.9
Read https:/ /docs.python. org/2/library/ decimal. html