random number in range code example

Example 1: Generate random number from range python

import random
nbr = random.randint(1, 10) 
print(nbr)

import numpy as np
uniform_nbrs = np.around(np.random.uniform(size=6), decimals=2)
print(uniform_nbrs)

Example 2: random range python

from random import randrange
print(randrange(10))

Example 3: random in range

// Get a random number between 20 and 30 
Math.round((Math.random() * (30 - 20 + 1)) + 20);

Example 4: function to get random number from min max range

funtion getRandomNumber(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max-min) )
}