Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created May 8, 2018 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/8786a42e23535ac6918303155479e255 to your computer and use it in GitHub Desktop.
Save Fhernd/8786a42e23535ac6918303155479e255 to your computer and use it in GitHub Desktop.
Redondear números punto flotante a una cantidad específica de decimales. OrtizOL.
import math
print(round(1.33, 1))
print(round(1.37, 1))
print(round(-1.37, 1))
print(round(math.pi, 3))
print(format(math.pi, '0.2f'))
print(format(math.pi, '0.3f'))
print('El valor de {} redondeado a 3 decimales es {:0.3f}'.format(math.pi, math.pi))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment