“Aléatoire” Réponses codées

aléatoire int entre deux nombres javascript

// Between any two numbers
Math.floor(Math.random() * (max - min + 1)) + min;

// Between 0 and max
Math.floor(Math.random() * (max + 1));

// Between 1 and max
Math.floor(Math.random() * max) + 1;
Calm Coyote

Python au hasard

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
Hurt Hippopotamus

JS Nombre aléatoire

var random;
var max = 8
function findRandom() {
  random = Math.floor(Math.random() * max) //Finds number between 0 - max
  console.log(random)
}
findRandom()
Determined Programmer

Aléatoire

Random rnd = new Random();
int rNum1 = random1.Next();

Console.WriteLine("ID : " + rNum1);
Encouraging Eel

Aléatoire

// Returns a number between 0 and 1
Math.random();
Thoughtless Tarantula

Aléatoire

# import random
import random
  
# prints a random value from the list
list1 = [1, 2, 3, 4, 5, 6]
print(random.choice(list1))
Idrone b2

Réponses similaires à “Aléatoire”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code