random Module

The random module generates pseudorandom numbers, integers within bounds, random booleans, alphanumeric strings, and performs array shuffling and element selection.

Importing

djazair
use random

API Reference

FunctionDescriptionExample
random.float()Uniform random float in [0.0, 1.0).random.float()
random.int(min, max)Random integer between min and max (inclusive).random.int(1, 100)
random.bool()Random boolean (True or False).random.bool()
random.string(length)Random alphanumeric string of given length.random.string(16)
random.choice(array)Selects a random element from an array.random.choice(["A", "B", "C"])
random.shuffle(array)Shuffles array elements in-place.random.shuffle(cards)
random.seed(number)Initializes PRNG seed for reproducible results.random.seed(12345)