lundi 5 décembre 2016

How to get random Decimal number from range?

I'm looking for a way how to generate random Decimal number within some range. For example -

>>> random.choice(range(Decimal(1.55,3.89)))

>>> 1.89

Is it possible to do that with random? I want to preserve 2 decimal places.

random.choice(range(Decimal(1.55,3.89))) 

returns >>> 0




Aucun commentaire:

Enregistrer un commentaire