1

Is there a way to tell python that I want to perform (all) my aritmetics rounding the results (always) to 3 decimals?

gabboshow
  • 5,359
  • 12
  • 48
  • 98

2 Answers2

2
num=1.2356
print round(num,3)
## Use round function and pass number of decimal places upto which you want to round
Poonam
  • 669
  • 4
  • 14
2

If it's only a matter of display, you can use numpy.set_printoptions(precision=3)

P. Camilleri
  • 12,664
  • 7
  • 41
  • 76
  • Thanks! can I ask you if Matlab and Python perform the aritmetics using the same num type? I am comparing results obtained with Matlab and Python and they don't match – gabboshow Nov 17 '16 at 09:19