I want to have Python declare a float
variable and then display that variable to two decimal points, even if the number is an integer. For example:
def floatToMoney:
# Some kind of function that outputs two decimal places
foo = float(6)
print(floatToMoney(foo))
boo = float(3.14159)
print(floatToMoney(boo))
and have an output of:
6.00
3.14
I know that round()
can do this, but again if the number is an integer it doesn't display the decimal places. I found the decimal
package, but is there any way to do this without having to import any packages?