Can someone explain to me in easy way the use of random and randint please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Can someone explain to me in easy way the use of random and randint please

random(0,9)

14th Apr 2017, 8:06 PM
Marta walter
Marta walter - avatar
5 Answers
+ 8
ok @awesome pls kindly view my comment on d code. I will appreciate any help
14th Apr 2017, 9:50 PM
CMD
CMD - avatar
+ 4
Important to remember though that random.randint treats both ends of the range argument INCLUSIVELY (unlike range(), which only has its left edge sharp). range: <x, y) randint: <x, y>
14th Apr 2017, 9:12 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
randint is like range range would go through all numbrs but randint would choose a number between it example from random import randint randint(0,50) prints a random number from 0-50 check out my profile for a code using randint its called rock paper scissor
14th Apr 2017, 8:14 PM
Nihad TK
Nihad TK - avatar
+ 2
edit: i also have another code using randint its very simple check it out you can understans randint thru it
14th Apr 2017, 8:15 PM
Nihad TK
Nihad TK - avatar
- 1
random.random() works the same but returns a random floating point number from 0 to 1.
14th Apr 2017, 8:20 PM
merkrafter