On this page
  1. random.uniform
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

random.uniform

Prev: random.triangular | Up: random | Next: random.vonmisesvariate
Rel: random.betavariate, random.binomialvariate, random.choice, random.choices
Ref: docs.python.org — random.uniform
Tags: #public #python3 #stdlib #random


Import

import random
from random import uniform

Signature & Overview

random.uniform(a, b)

Get a random number in the range [a, b) or [a, b] depending on rounding.

Usage

import random

rng = random.Random(1)
x = rng.uniform(2.5, 5.5)
assert 2.5 <= x <= 5.5

Gotchas

REPL Inspect

from random import uniform
help(uniform)

Linked from

Related notes