Basically i understand the program but not the math/numbers used here.
import random
def r_int():
x = int(abs(10 * random.random() % 20))
return x
I figured out this is equivalent to random.randint(0,9)
. What does the %
and 20
do here?
Aucun commentaire:
Enregistrer un commentaire