I am trying to reduce the number of decimal places that I get after some calculations. print() , where my problem occurs, is as follows:
print("Mean resistivity: {res} Ohm m".format(res=np.mean(resistivity)))
And he deduces this:
Mean resistivity: 1.6628449915450776e-08 Ohm m
Now I want to reduce the number of decimal places that were printed to 3. I tried doing this with string formatting, for example:
print("Mean resistivity: {res:.3f} Ohm m".format(res=np.mean(resistivity)))
However, this code prints:
Mean resistivity: 0.000 Ohm m
I really want:
Mean resistivity: 1.663e-8 Ohm m
How can I format res only for display as scientific notation, but with only three decimal places?
source share