python - Could random.randint(1,10) ever return 11? -
random.py while reading and reading the source code, I started thinking that Rudraz and randink actually behaves in the form of "advertised" I want to believe a lot, but the way I read it, RudraZ is essentially implemented
start + int (random.random () * (stop ( start < For integer values for / code> and stop ), Therefore a random number should be returned between randrange (1, 10)
/ code> between 1 and 9.
Randink (Start, Stop) Calling randrange (start, stop + 1) , which can return a number between 1 and 10.
My question is now Is:
If random () 1.0 code>, then randint (1,10) back 11 Will not,
to random.py and Docs:
) indicates that the interval is exclusive 1.0. It is, it will never return.
This is a general conference in mathematics, [ and ] is inclusive, while ( and ) Unique, and the two types of parentheses can be mixed in the form of (a, b) or [a, b} . A glance for formal explanation Enter
Comments
Post a Comment