Home >>Python Random Module >Python Random triangular() Method

Python Random triangular() Method

Python Random triangular() Method

Python Random triangular() Method in python returns a random floating number between the two specified numbers i.e x and y but you can also specify a third parameter.

Syntax:
random.triangular(low, high, mode)

Parameter Values

Parameter Description
low It is Optional. The lowest possible outcome to specify the number. The default value is 0
high It is Optional. The highest possible outcome to specify the number. The default value is 1
mode It is Optional. The midpoint between the low and high values by default
Here is an example of Python Random triangular() Method:

import random
print(random.triangular(14, 45, 15))

Output:
24.171033741431227
Example 2:

import random
print(random.triangular(34, 27, 67))

Output:
30.000085210678662

No Sidebar ads