logo

Programming Languages - Random

Java

Random random = new Random(System.currentTimeMillis())

JavaScript

Generate a random number between 0 and 1:

Math.random();

Generate a random integer:

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}

Python

>>> import random
>>> random.random()
0.12062307072338296