def f(x, i): return x/(10**i)
python3で。