I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5 → 5.00, 5.5 → 5.50, etc). How can I do this in Python?
I have a function taking float arguments (generally integers or decimals with one significant
Share
You could use the string formatting operator for that:
The result of the operator is a string, so you can store it in a variable, print etc.