A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://microbit-micropython.readthedocs.io/en/latest/random.html below:

Website Navigation


Random Number Generation — BBC micro:bit MicroPython 1.1.1 documentation

Random Number Generation

This module is based upon the random module in the Python standard library. It contains functions for generating random behaviour.

To access this module you need to:

We assume you have done this for the examples below.

Functions
random.getrandbits(n)

Returns an integer with n random bits.

Warning

Because the underlying generator function returns at most 30 bits, n may only be a value between 1-30 (inclusive).

random.seed(n)

Initialize the random number generator with a known integer n. This will give you reproducibly deterministic randomness from a given starting state (n).

random.randint(a, b)

Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).

random.randrange(stop)

Return a randomly selected integer between zero and up to (but not including) stop.

random.randrange(start, stop)

Return a randomly selected integer from range(start, stop).

random.randrange(start, stop, step)

Return a randomly selected element from range(start, stop, step).

random.choice(seq)

Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError.

random.random()

Return the next random floating point number in the range [0.0, 1.0)

random.uniform(a, b)

Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4