Python math模块中定义了一些数学函数。由于这个模块属于编译系统自带,因此它可以被无条件调用。该模块还提供了与用标准C定义的数学函数的接口。本文主要介绍Python math.gamma() 方法的使用,以及相关示例代码。

Python math.gamma() 方法

Python Math方法

例如:

求不同数的函数:

# Import math Library
import math

# 为不同的数字返回gamma函数
print(math.gamma(-0.1))
print(math.gamma(8))
print(math.gamma(1.2))
print(math.gamma(80))
print(math.gamma(-0.55))

1、定义和用法

math.gamma()方法以数字形式返回gamma函数。

提示:要查找数字的对数伽马值,请使用math.lgamma()方法。

2、调用语法

math.gamma(x)

3、参数说明

参数

描述

x

必需的参数, 查找伽玛函数的数字。 如果数字是负整数,

则返回ValueError。 如果不是数字,则返回TypeError。

4、方法说明

返回值:

float值,表示x处的伽玛函数

Python Version:

3.2

Python Math方法

推荐文档