haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Python 3: Module math - mathematical functions

已有 2610 次阅读 2016-11-17 22:35 |个人分类:Python|系统分类:科研笔记| module, functions, math, Mathematical

>>> import math


# math.floor(x) returns the floor of x as a float, the largest integer value less than or equal to x.
>>> math.floor(9.2)

9.0


# math.sqrt(x) returns the square root of x.

>>> math.sqrt(81)

9.0


# math.pow(x,y) returns x raised to the power y.

>>> math.pow(2,3)

8.0


# math.log10(x) returns the base-10 logarithm of x.

>>> math.log10(100)
2.0


# math.exp(x) returns e**x.

>>> math.exp(2)

7.38905609893065


# check if the float x is a NaN

>>> math.isnan(x)


# equivalent to the output of float('nan').
>>> math.nan  # python3

nan


>>> math.pi
3.141592653589793


>>> math.e
2.718281828459045




https://wap.sciencenet.cn/blog-3031432-1015385.html

上一篇:Python: operators
下一篇:Python 2: strings
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-5 04:50

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部