Skip to main content
Post Undeleted by Dennis
deleted 10 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2Python 3 + SymPy, 6854 bytes

from sympy import*
lambda s,p:`Rational'%.*f'%(p,S(s).round(p)`[:-0**p or None])

Try it online!Try it online!

Python 2 + SymPy, 68 bytes

from sympy import*
lambda s,p:`Rational(s).round(p)`[:-0**p or None]

Try it online!

Python 3 + SymPy, 54 bytes

from sympy import*
lambda s,p:'%.*f'%(p,S(s).round(p))

Try it online!

Post Deleted by Dennis
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python 2 + SymPy, 68 bytes

from sympy import*
lambda s,p:`Rational(s).round(p)`[:-0**p or None]

Try it online!