I'm trying to make a rounding function in Python to make proper significant figures but I don't know how to remove the quotes from the answer, an ex. is '156.70', I want to have the number with 2 decimal place precision, and
round(156.70,2)
returns 156.7.
I have tried this: format(round(156.70,2),'.2f')
, but it places the answer in single quotes like I stated above. Is there a way to round directly with the floating point zero, or is there a way to remove the quotes?
I have also tried the strip command which does not remove the quotes.
I also tried converting the answer (156.70) to a numpy array to remove the quotes the following way:
ares1 = np.array(format(round(ans,2),".2f"))
values = ares1.item().split(' ')
ares = np.asarray(values, dtype='float')
Where 'ans' is the value 156.7 I want to round to two precision points. Thanks for any help.