lundi 19 mars 2018

Generate a random number between two numbers that contain decimals

As the title says, I'm having trouble figuring out how to generate a random number between two numbers that contain decimals. My code is as follows:

import random as rd
x = rd.randrange(15.5, 20.5, 0.1)
print(x)

However, when I run it I receive this error:

ValueError: non-integer arg 1 for randrange()

My question is, what command can I use that functions as randrange for numbers with decimals?




Aucun commentaire:

Enregistrer un commentaire