pfun.random.Random
dataclass
Module that provides random number generation
randint(self, a, b)
Create an Effect
that succeeds with a random integer n
in the range a <= n <= b
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
int |
lower bound |
required |
b |
int |
upper bound |
required |
Returns:
Type | Description |
---|---|
pfun.effect.Effect[object, NoReturn, int] |
|
random(self)
Create an Effect
that succeeds with a random float between 0.0 and 1.0
Returns:
Type | Description |
---|---|
pfun.effect.Effect[object, NoReturn, float] |
|
pfun.random.HasRandom
Module provider for the random module
Attributes:
Name | Type | Description |
---|---|---|
random |
Random |
The random module |
pfun.random.random()
Create an Effect
that succeeds with a random float between 0.0 and 1.0
Examples:
>>> from pfun import DefaultModules
>>> random().run(DefaultModules)
0.575351197
Returns:
Type | Description |
---|---|
pfun.effect.Effect[pfun.random.HasRandom, NoReturn, float] |
|
pfun.random.randint(a, b)
Create an Effect
that succeeds with a random integer n
in the range a <= n <= b
.
Examples:
>>> from pfun import DefaultModules
>>> randint(0, 1).run(DefaultModules())
0
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
int |
lower bound |
required |
b |
int |
upper bound |
required |
Returns:
Type | Description |
---|---|
pfun.effect.Effect[pfun.random.HasRandom, NoReturn, int] |
|