The leading zeroes challenge

Pyth, 12 bytes

%"%0*d",+E>0

Try it here!


Python 2, 29 bytes

lambda x,y:x.zfill(y+(x<'.'))

Try it online!

Just str.zfill comes so close.


Python, 29 bytes

Take input as f(x,y). Using Python's % operator.

lambda x,y:'%0*d'%(y+(x<0),x)

Try it online!