random code example

Example 1: random int between two numbers 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;

Example 2: js random number

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

Example 3: python random

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

Example 4: random js

function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min)) + min + 1;
}

Example 5: random

Welcome to your life as a wizard or witch. Make friends, trade knowledge of locations and spells. Forge your story...

Here are some of the spells to get your adventure started:
Expelliarmus
Sectumsempra
Lumos
Expecto Patronum
Anteoculatia
Orchideous
Tarantallegra

Teachers of the Wizard School, please do remember to teach that Q is used to block incoming spells.

You need galleons to buy some spells like avada kedavra.

Example 6: random

Welcome to your life as a wizard or witch. Make friends, trade knowledge of locations and spells. Forge your story...

Here are some of the spells to get your adventure started:
Expelliarmus
Sectumsempra
Lumos
Expecto Patronum
Anteoculatia
Orchideous
Tarantallegra

Teachers of the Wizard School, please do remember to teach that Q is used to block oncoming spells.

Tags: