Python‎ > ‎random‎ > ‎

random.triangular()


Introduction
The triangular(low=0.0, high=1.0, mode=None) method of random.Random instance Triangular distribution.

Syntax
random.triangular()

Parameters
None

Examples
The method returns with the random value:
import random
x=random.triangular(5,200)
print(x)

>>> 
113.86865896288101
>>>

The method returns with the for loop after finding the subtraction of random values.
import operator
import random
a=random.triangular(7,14)
b=random.uniform(2,5)
x=int(round(operator.sub(a,b)))
for i in range(x, 30):
    print(i)
    if i.__ge__(30):
        b=int(round(random.paretovariate(3)))
        print(i)

>>> 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
>>>


Comments