mardi 17 janvier 2017

Generate a float random number with one number afer decimal point [duplicate]

This question already has an answer here:

I have two float numbers where both have one number after the decimal point. I want to generate a a random float where only the first number after the decimal point count .

Example:

Let's say we have two numbers : 3.5 and 3.8, I want a way to generate a random number like 3.6 and 3.7, I don't want to generate numbers like 3.58 or 3.584 and so one, I want a random float number .

I can't use random.uniform(a,b) because it doesn't do what I want, it can generate random numbers for other numbers after decimal point (second and third number after decimal point like 3.589)




Aucun commentaire:

Enregistrer un commentaire