python——数学模块(math模块)(2)

简介: python——数学模块(math模块)(2)

pow(x, y)

返回 x 的 y 次幂。看下示例:

import math
x = 3
y = 2
print(math.pow(x, y))

fsum(iterable)

返回迭代器中所有元素的和。看下示例:

import math
print(math.fsum((1, 2, 3, 4, 5)))

gcd(x, y)

返回整数 x 和 y 的最大公约数。看下示例:

import math
x = 9
y = 6
print(math.gcd(x, y))

sqrt(x)

返回 x 的平方根。看下示例:

import math
x = 9
print(math.sqrt(x))


trunc(x)

返回 x 的整数部分。看下示例:

import math
x = 1.1415926
print(math.trunc(x))

exp(x)

返回 e 的 x 次幂。看下示例:

import math
x = 2
print(math.exp(2))

log(x[, base])

返回 x 的对数,底数默认为 e。看下示例:

import math
x = 10
y = 10
# 不指定底数
print(math.log(x))
# 指定底数
print(math.log(x, y))


相关文章
|
6天前
|
JSON API 数据格式
30天拿下Python之requests模块
30天拿下Python之requests模块
18 7
|
5天前
|
人工智能 数据可视化 搜索推荐
Python异常模块与包
Python异常模块与包
|
5天前
|
Linux Python Windows
一个Python模块Pendulum的问题
一个Python模块Pendulum的问题
11 0
|
6天前
|
API Python
30天拿下Python之matplotlib模块
30天拿下Python之matplotlib模块
|
6天前
|
SQL 数据处理 数据库
30天拿下Python之pandas模块
30天拿下Python之pandas模块
|
6天前
|
存储 索引 Python
30天拿下Python之numpy模块
30天拿下Python之numpy模块
10 0
|
6天前
|
开发者 Python
30天拿下Python之logging模块
30天拿下Python之logging模块
|
6天前
|
安全 索引 Python
30天拿下Python之collections模块
30天拿下Python之collections模块
|
6天前
|
SQL 数据库连接 数据库
30天拿下Python之sqlite3模块
30天拿下Python之sqlite3模块
|
6天前
|
Unix 数据安全/隐私保护 Python
30天拿下Python之shutil模块
30天拿下Python之shutil模块
下一篇
无影云桌面