1.math简介

>>>import math      #导入math模块
>>>dir(math) #这句可查看所有函数名列表
>>>help(math) #查看具体定义及函数原型
 

2.常用函数

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模块的更多相关文章

  1. python 的math模块

    数学模块用法:import math# 或 from math import * 变量 描述 math.e 自然对数的底e math.pi 圆周率pi 函数名 描述 math.ceil(x) 对x向上 ...

  2. python 之math模块

    一.math 简介 import math # 导入模块 ret = dir(math) # 查看所有函数名列表 print(ret) # ['__doc__', '__loader__', '__n ...

  3. python中math模块常用的方法整理

    ceil:取大于等于x的最小的整数值,如果x是一个整数,则返回x copysign:把y的正负号加到x前面,可以使用0 cos:求x的余弦,x必须是弧度 degrees:把x从弧度转换成角度 e:表示 ...

  4. Python的math模块

    ceil(x) 返回整数 >>> math.ceil(-1.273) -1 >>> math.ceil(1.33) 2 copysign(x,y) 把y的符号给x, ...

  5. (转)python中math模块常用的方法整理

    原文:https://www.cnblogs.com/renpingsheng/p/7171950.html#ceil ceil:取大于等于x的最小的整数值,如果x是一个整数,则返回x copysig ...

  6. 【转载】python中math模块常用的方法

    转自:https://www.cnblogs.com/renpingsheng/p/7171950.html ceil #取大于等于x的最小的整数值,如果x是一个整数,则返回x ceil(x) Ret ...

  7. Python:python中math模块中提供的基本数学函数

    sin(x):求x的正弦 cos(x):求x的余弦 asin(x):求x的反正弦 acos(x):求x的反余弦 tan(x):求x的正切 atan(x):求x的反正切 hypot(x,y):求直角三角 ...

  8. Python:基本运算、基本函数(包括复数)、Math模块、NumPy模块

    基本运算 x**2 : x^2 若x是mat矩阵,那就表示x内每个元素求平方 inf:表示正无穷 逻辑运算符:and,or,not 字典的get方法 a.get(k,d) 1 1 get相当于一条if ...

  9. Python常用的一些内建函数和math模块函数

    一:Python内建函数 # abs取绝对值 num = -10 print(abs(num)) # max 求最大值 print(max(6, 9, 2, 12, 8)) # min求最小值 pri ...

随机推荐

  1. 查找——图文翔解Treap(树堆)

    之前我们讲到二叉搜索树,从二叉搜索树到2-3树到红黑树到B-树. 二叉搜索树的主要问题就是其结构与数据相关,树的深度可能会非常大,Treap树就是一种解决二叉搜索树可能深度过大的还有一种数据结构. T ...

  2. _视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear等的区别及用途

    iOS视图控制对象生命周期-init.viewDidLoad.viewWillAppear.viewDidAppear.viewWillDisappear.viewDidDisappear的区别及用途 ...

  3. 关于响应式、媒体查询和media的关系 、流媒体布局flex 和em rem像素的使用 我有一些废话要讲.....

    一.什么是响应式 随着移动端越来遇火 网站的布局成为一个热议的话题 有的人喜欢用手机浏览网站.有的人喜欢用paid浏览网站.有人喜欢用电脑浏览网站 那么问题来了 我们怎么样才能使用一套css样式 完成 ...

  4. CheckBox只选择一项

    最近做一个问卷的页面,客户那边说要使用checkbox而且只能选择一项 就写了下面的代码 <html xmlns="http://www.w3.org/1999/xhtml" ...

  5. iOS App集成Apple Pay教程(附示例代码)

    苹果在本周一发布了iOS 8.1版本,并正式开放了Apple Pay支付系统.Apple Pay是一个基于NFC的支付系统,不久将被数以万计的线下零售商店予以支持.即便这项科技并不是彻底的突破性进展, ...

  6. 启动tomcat的时候,服务器暂停到装载mysql驱动文件的原因

    1.使用spring+mybatis,由于mybatis的配置文件中jdbc类型的错误使得,tomcat无法正常启动,在编写mybatis一定确保jdbc类型,java类型正确,jdbc类型要大写! ...

  7. Easyui + jQuery表单提交 给 Controller patr1

    2014-11-15  总结上周在公司开发所用到的技术,由于是刚找的工作(一个大三实习生)+自己的技术菜,有很多地方都是怎么想就怎么实现的, 如果你有什么更好的解决方法,在看见这篇博客的时候,希望你能 ...

  8. delphi R3下 跨进程获取DLL信息 NtQueryInformationProcess

    unit APIUnit; { GetProcessModuleHandle API Unit Ring3调用NtQueryInformationProcess实现跨进程获取DLL句柄 } inter ...

  9. 上星期IOS的一个面试题。

    美丽说面试题 1,IOS是怎样进行内存管理的,什么是ARC. 2,声明Property时,assign,nonatomic,readonly,retain,copy(各什么意思,括号里没打印出来,我猜 ...

  10. Core第三方开源Web框架

    NET Core第三方开源Web框架YOYOFx   YOYOFx框架 YOYOFx是一个轻量级用于构建基于 HTTP 的 Web 服务,基于 .NET 和 Mono 平台. 本着学习的态度,造了这个 ...