How to pretty print a list of floats in Python

Pretty printing floats formats their output to a desired number of decimal places.

Solution for How to pretty print a list of floats in Python : You can use numpy.set_printoptions() to pretty print a list of floats Call numpy.array(object) with object as a list of floats to convert object to a NumPy array. Call numpy.set_printoptions(precision=n) to inlcude only n decimal places when printing the array.


how-to-pretty-print-a-list-of-floats-in-python