Pythonランダムユニフォーム()メソッド
例
20と60の間の乱数を返します。
import random
print(random.uniform(20, 60))
定義と使用法
このuniform()
メソッドは、指定された2つの数値(両方を含む)の間のランダムな浮動小数点数を返します。
構文
random.uniform(a, b)
パラメータ値
Parameter | Description |
---|---|
a | Required. A number specifying the lowest possible outcome |
b | Required. A number specifying the highest possible outcome |