Dz
Djazair
v1.0.5
🔍

Random Module

Import using: use random

random.float()

Returns a random float in [0.0, 1.0) with uniform distribution.

use random
print(str(random.float()))
print(str(random.float()))

random.int(min, max)

Returns a random integer in [min, max] inclusive.

use random
print(str(random.int(1, 10)))    # e.g. 7
print(str(random.int(100, 200)))

random.bool()

Returns a random boolean with equal probability.

use random
print(str(random.bool()))  # True or False
# Distribution check
let tc = 0
let fc = 0
let i = 0
while i < 1000
    if random.bool()
        tc += 1
    else
        fc += 1
    end
    i += 1
end
print("true=" + str(tc) + " false=" + str(fc))

random.string(length)

Returns a random alphanumeric string of given length ([a-zA-Z0-9]).

use random
print(random.string(8))   # e.g. "aB3xK9mQ"
print(random.string(16))
let s = random.string(20)
print(str(s.length()))  # 20

random.bytes(length)

Returns an array of random bytes of given length.

use random
let b = random.bytes(8)
print(str(b))               # e.g. [42, 15, 230, ...]
print(str(b.length()))      # 8

random.choice(array)

Picks a random element from an array. Returns Null if empty.

use random
let fruits = ["apple", "banana", "cherry"]
print(random.choice(fruits))   # random fruit
print(str(random.choice([])))  # Null

random.shuffle(array)

Fisher-Yates shuffle in-place. Returns the array.

use random
let deck = ["A", "B", "C", "D", "E"]
random.shuffle(deck)
print(str(deck))  # Shuffled order
© 2026 Harizi Riyadh. Released under the MIT License.
Official Website for Djazair.