Nono.MA

Random numbers in Python

FEBRUARY 2, 2023

Here's how to generate pseudo-random numbers in Python.

import random

# Random generation seed for reproducible results
seed = 42

# Float
random.Random(seed).uniform(3,10)
# 7.475987589205186

# Integer
int(random.Random(seed).uniform(3,10))
# 7

# Integer
random.Random(seed).randint(0, 999)
# 654

See the random module for more information.

BlogCodePythonTil