0
I’m making a simple program that generates two random numbers and asks the user how much is that number +,-,/,* for another number, and I want them to have decimal numbers as well, but when I use the uniform()
It generates a lot of decimals, and I don’t want that, I want to limit it to three houses. But I need to do this right in the definition of variables, and this I don’t know how, does anyone know?
Code:
n1 = str(uniform(1,1000))
# gera um número float de 1 à 999.
n2 = str(uniform(1, 1000))
# gera um número float de 1 à 999.
(I’m using str to use in the future on an Eval)
View the library decimal
– Paulo Marques