def my_round(n, ndigits):
    part = n * 10 ** ndigits
delta = part - int(part)
if delta >= 0.5 or -0.5 < delta <= 0:
    part = math.ceil(part)
else:
    pass
python incorrect rounding with floating point numbers