python 之math模块
一.math 简介
import math # 导入模块 ret = dir(math) # 查看所有函数名列表
print(ret)
# ['__doc__', '__loader__', '__name__', '__package__', '__spec__',
# 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil',
# 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp',
# 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum',
# 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite',
# 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p',
# 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh',
# 'sqrt', 'tan', 'tanh', 'tau', 'trunc'] ret = help(math) # 查看具体定义 以及 函数 原型
print(ret)
二.常用函数 简介
acos(x) # Return the arc cosine (measured in radians) of x. asin(x) # Return the arc sine (measured in radians) of x. atan(x) # Return the arc tangent (measured in radians) of x. atan2(y, x) # Return the arc tangent (measured in radians) of y/x.
# Unlike atan(y/x), the signs of both x and y are considered. ceil(x) # Return the ceiling of x as a float.
# This is the smallest integral value >= x. cos(x) # Return the cosine of x (measured in radians). cosh(x) # Return the hyperbolic(双曲线的) cosine of x. degrees(x) # converts angle x from radians(弧度) to degrees exp(x) # Return e raised to the power of x. fabs(x) # Return the absolute value of the float x. floor(x) # Return the floor of x as a float.
# This is the largest integral value <= x. fmod(x,y) # Return fmod(x, y), according to platform C. x % y may differ. frexp(x) # Return the mantissa and exponent of x, as pair (m, e).
# m is a float and e is an int, such that x = m * 2.**e.
# If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. hypot(x,y) # Return the Euclidean distance, sqrt(x*x + y*y). ldexp(x, i) # x * (2**i) log(x[, base]) # the logarithm of x to the given base.
# If the base not specified, returns the natural logarithm (base e) of x. log10(x) # the base 10 logarithm of x. modf(x) # Return the fractional and integer parts of x. Both results carry the sign
# of x. The integer part is returned as a real. pow(x,y) # Return x**y (x to the power of y). radians(x) # converts angle x from degrees to radians sin(x) # Return the sine of x (measured in radians). sinh(x) # Return the hyperbolic sine of x. sqrt(x) # Return the square root of x. tan(x) # Return the tangent of x (measured in radians). tanh(x) # Return the hyperbolic tangent of x.
三.该模块定义了两个常量
e = 2.7182818284590451 pi = 3.1415926535897931
python 之math模块的更多相关文章
- python之math模块
1.math简介 >>>import math #导入math模块 >>>dir(math) #这句可查看所有函数名列表 >>>help(math ...
- python 的math模块
数学模块用法:import math# 或 from math import * 变量 描述 math.e 自然对数的底e math.pi 圆周率pi 函数名 描述 math.ceil(x) 对x向上 ...
- python中math模块常用的方法整理
ceil:取大于等于x的最小的整数值,如果x是一个整数,则返回x copysign:把y的正负号加到x前面,可以使用0 cos:求x的余弦,x必须是弧度 degrees:把x从弧度转换成角度 e:表示 ...
- Python的math模块
ceil(x) 返回整数 >>> math.ceil(-1.273) -1 >>> math.ceil(1.33) 2 copysign(x,y) 把y的符号给x, ...
- (转)python中math模块常用的方法整理
原文:https://www.cnblogs.com/renpingsheng/p/7171950.html#ceil ceil:取大于等于x的最小的整数值,如果x是一个整数,则返回x copysig ...
- 【转载】python中math模块常用的方法
转自:https://www.cnblogs.com/renpingsheng/p/7171950.html ceil #取大于等于x的最小的整数值,如果x是一个整数,则返回x ceil(x) Ret ...
- Python:python中math模块中提供的基本数学函数
sin(x):求x的正弦 cos(x):求x的余弦 asin(x):求x的反正弦 acos(x):求x的反余弦 tan(x):求x的正切 atan(x):求x的反正切 hypot(x,y):求直角三角 ...
- Python:基本运算、基本函数(包括复数)、Math模块、NumPy模块
基本运算 x**2 : x^2 若x是mat矩阵,那就表示x内每个元素求平方 inf:表示正无穷 逻辑运算符:and,or,not 字典的get方法 a.get(k,d) 1 1 get相当于一条if ...
- Python常用的一些内建函数和math模块函数
一:Python内建函数 # abs取绝对值 num = -10 print(abs(num)) # max 求最大值 print(max(6, 9, 2, 12, 8)) # min求最小值 pri ...
随机推荐
- kdd cup 2019
比赛简介: 任务1:推荐最佳交通方式 任务描述:给定用户的一些信息,预测用户使用何种最佳交通方式由O(起点)到D(终点) 数据描述: profiles.csv: 属性pid:用户的ID: 属性p0~p ...
- golang struct组合,转型问题请教
type Action interface { OnHurt2(other Action) GetDamage() int } type Base struct { atk, hp int } fun ...
- Spark源码资料汇总
近几月,想要了解Spark的内部实现原理,因此想要查阅Spark的源码信息,现将所了解的资料汇总如下: 1. 博客文字类 (1) 官网 1) github 2) Spark官网 (2) gitbook ...
- modbus4j中使用modbus tcp/ip和modbus rtu over tcp/ip模式
通过借鉴高人博客,总结如下: 1. TcpMaster类,用于生成ModbusMaster主类 package sun.sunboat; public class TcpMaster { privat ...
- 最新 人民网java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.人民网等10家互联网公司的校招Offer,因为某些自身原因最终选择了人民网.6.7月主要是做系统复习.项目复盘.LeetCo ...
- java中类加载的全过程及内存图分析
类加载机制: jvm把class文件加载到内存,并对数据进行校验.解析和初始化,最终形成jvm可以直接使用的java类型的过程. (1)加载 将class文件字节码内容加载到内存中,并将这些静态数据转 ...
- Linux用户管理重要初始化目录login
/etc/login.defs 配置文件 /etc/login.defs 文件是用来定义创建用户时需要的一些用户的配置信息.如创建用户时,是否需要家目录,UID和GID的范围,用户及密码的有效期限等 ...
- Java反射:Web学习的灵魂
反射:Web学习的灵魂 我们从最初的 javac -HelloWorld.java,到面向对象部分,我们可以将Java代码在计算机中经历的阶段分为三部分:Scource源代码阶段 -- Class类对 ...
- Java网络编程-你是GG还是MM?
第六阶段 网络编程 每一台计算机通过网络连接起来,达到了数据互动的效果,而网络编程所解决的问题就是如何让程序与程序之间实现数据的通讯与互动 在吗?你是GG还是MM? (一) 网络模型概述 (1) 两大 ...
- Centos7查看关闭防火墙
查看防火墙状态: firewall-cmd --state 关闭防火墙 service firewalld start 开机启动 service firewalld stop 禁止开机启动 syste ...