Méthode Python Random Randrange ()
Exemple
Renvoie un nombre entre 3 et 9 :
import random
print(random.randrange(3, 9))
Définition et utilisation
La randrange()
méthode renvoie un élément sélectionné au hasard dans la plage spécifiée.
Syntaxe
random.randrange(start, stop, step)
Valeurs des paramètres
Parameter | Description |
---|---|
start | Optional. An integer specifying at which position to start. Default 0 |
stop | Required. An integer specifying at which position to end. |
step | Optional. An integer specifying the incrementation. Default 1 |