.format in python rounding code example Example: print format round python >>> '{number:.{digits}f}'.format(number=p, digits=n) '3.1416'