+ 12

Python Module [RANDOM]

Please I need more insight on the differences between two methods in the Random module: randrange and randint. And also tell me more useful Random methods.

14th Dec 2017, 5:30 AM
Justine Ogaraku
Justine Ogaraku - avatar
12 odpowiedzi
+ 12
@justone ... you will find your answer..in @David's post
14th Dec 2017, 7:44 AM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
+ 10
No problem @Nerf. Hope you'll enjoy SoloLearn
14th Dec 2017, 11:43 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 10
No problem @Nerf. Hope you'll enjoy SoloLearn
14th Dec 2017, 11:43 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 9
How can I get the documentation, is it on Python site??
14th Dec 2017, 6:03 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 8
randint includes the specified upper bound; randrange works more like Python range: the specified upper bound is not included in the range. So e.g. randint(6,8) will yield 6, 7 or 8. But randrange(6,8) will yield 6 or 7.
14th Dec 2017, 5:35 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 7
Just reviewed the official docs. randint (a,b) is simply an alias for randrange(a,b+1). Which is consistent with my first answer.
14th Dec 2017, 5:38 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 7
Here is a link to the official documentation https://docs.python.org/3/library/random.html
14th Dec 2017, 6:59 AM
David Ashton
David Ashton - avatar
+ 7
what's that @Elisei??
14th Dec 2017, 6:19 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 5
Besides Python Official Documentation, this site is very helpful on finding Python modules explanation and examples: https://pymotw.com/3/random/index.html
15th Dec 2017, 5:13 AM
noobcøder
noobcøder - avatar
+ 2
You can simply search “Random module python” on google and it should show up.
14th Dec 2017, 6:04 AM
Adam
Adam - avatar
+ 1
RandRange- Uses an external command (getrandbits), and skips the third paramater (to my knowledge) RandInt- Just chooses a random int between (and including) X & Y
14th Dec 2017, 5:33 AM
Adam
Adam - avatar
+ 1
I don't know I'm a noob i installed this app today
14th Dec 2017, 11:16 AM
Nerf pup