What is the basic function of random number? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the basic function of random number?

answer in easy way

14th Aug 2017, 1:31 PM
RahulShukla
RahulShukla - avatar
2 Answers
+ 1
You use random to mimic unpredictable events. For example what's the face of the next coin flip? You'll most likely deal with random when playing games:- ✅ What's the chance for getting a rare item in game? ✅ What's the chance to break my equipment during upgrade? It's all about RNG (random number generator) when we deal with chance/uncertainty in-game.
14th Aug 2017, 2:11 PM
Zephyr Koo
Zephyr Koo - avatar
+ 1
python : from random import * print(randint(1,7),randrange(18)) C++: #include <csdtio> #include <ctime> #include <iostream> int main(){ srand(time(0)); for(int i=1;i<11;++i) std::cout<<rand()%(i*10)<<std::endl; return 0; }
14th Aug 2017, 2:12 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar