math.fabs

Python math.fabs()方法 (Python math.fabs() method)

math.fabs() method is a library method of math module, it is used to get the absolute value of a number, it accepts a number (that can be either positive integer/float or negative integer/float) and returns an absolute value in the float type.

math.fabs()方法数学模块的库方法,用于获取数字的绝对值,它接受数字(可以为正整数/浮点数或负整数/浮点数)并返回绝对值在浮点类型。

Syntax of math.fabs() method:

math.fabs()方法的语法:

    math.fabs(n)

Parameter(s): n – a number or a numeric expression.

参数: n-数字或数字表达式。

Return value: float – it returns a float value, which is an absolute value of given number/numeric expression n.

返回值: float-返回浮点值,它是给定数字/数字表达式n的绝对值。

Example:

例:

    Input:
a = -10
b = 10.23
# function call
print(math.fabs(a))
print(math.fabs(b))
Output:
10.0
10.23

Python代码演示math.fabs()方法的示例 (Python code to demonstrate example of math.fabs() method)

# Python code to demonstrate example of
# math.fabs() method
# importing math module
import math
# numbers
a = 10      # +ve integer
b = 10.23   # +ve float
c = -10     # -ve integer
d = -10.23  # -ve float
# printing absolute values
print("fabs(a): ", math.fabs(a))
print("fabs(b): ", math.fabs(b))
print("fabs(c): ", math.fabs(c))
print("fabs(d): ", math.fabs(d))

Output

输出量

fabs(a):  10.0
fabs(b):  10.23
fabs(c):  10.0
fabs(d):  10.23

翻译自: https://www.includehelp.com/python/math-fabs-method-with-example.aspx

math.fabs

math.fabs_带有Python示例的math.fabs()方法相关推荐

  1. math.trunc_带有Python示例的math.trunc()方法

    math.trunc Python math.trunc()方法 (Python math.trunc() method) math.trunc() method is a library metho ...

  2. math.atan2_带有Python示例的math.atan2()方法

    math.atan2 Python math.atan2()方法 (Python math.atan2() method) math.atan2() method is a library metho ...

  3. js math.hypot_带有Python示例的math.hypot()方法

    js math.hypot Python math.hypot()方法 (Python math.hypot() method) math.hypot() method is a library me ...

  4. python math.sinh_带有Python示例的math.sinh()方法

    Python math.sinh() 方法 math.sinh()方法是数学模块的一种库方法,用于获取以弧度为单位的给定数字的双曲正弦值,它接受一个数字并返回双曲正弦值. 注意: math.sinh( ...

  5. np.isfinite_带有Python示例的math.isfinite()方法

    np.isfinite Python math.isfinite()方法 (Python math.isfinite() method) math.isfinite() method is a lib ...

  6. factorial函数_带有Python示例的math.factorial()方法

    factorial函数 Python math.factorial()方法 (Python math.factorial() method) math.factorial() method is a ...

  7. np.copysign_带有Python示例的math.copysign()方法

    np.copysign Python math.copysign()方法 (Python math.copysign() method) math.copysign() method is a lib ...

  8. 带有Python示例的math.sin()方法

    Python math.sin()方法 (Python math.sin() method) math.sin() method is a library method of math module, ...

  9. tf.acos_带有Python示例的math.acos()方法

    tf.acos Python math.acos()方法 (Python math.acos() method) math.acos() method is a library method of m ...

最新文章

  1. Pytorch实现MNIST(附SGD、Adam、AdaBound不同优化器下的训练比较) adabound实现
  2. CentOS系统环境下安装MongoDB
  3. 如何大写字符串中每个单词的第一个字符
  4. 数据科学家最需要什么技能?
  5. 由浅到深理解ROS(9)- 几个基本概念的理解 坐标系 包
  6. structs2之多文件上传
  7. 斗地主AI算法——第三章の数据处理
  8. ubuntu Gitolite管理git server代码库权限
  9. volatile学习
  10. Producer Consumer
  11. 【git系列】提交新的PR-撤销git rebase
  12. Unix/Linux笔记全集
  13. 【二维码识别】基于matlab GUI 灰度+二值化+校正二维码生成与识别【含Matlab源码 635期】
  14. 嵌入式设备系统有无操作系统的区别
  15. 数据库binlog(二进制日志binary log)
  16. html td无边框颜色,table的td设置背景颜色后边框框消失
  17. 毕业论文排版及格式修改“骚操作”和常见误区(Word基础)
  18. 【Lua】Lua基础语法
  19. 系统架构-基础篇-(高性能基础建设说明与选型条件)
  20. 假设检验:一个总体参数的检验、总体方差检验、两个总体参数的检验和两个总体方差的检验

热门文章

  1. RHEL7 修改SSH默认端口
  2. JDK源码解析之 java.lang.Error
  3. 为什么MIP-Cache存在
  4. Problem B: 求各位数字之和
  5. 二十多岁不信,三十多岁却深信不疑的道理
  6. 如何通过BBED找回删除数据
  7. iOS:个人浅谈工厂模式
  8. data.frame类型数据如何将第一列值替换为行号
  9. [转]“Ceph浅析”系列之(—)—Ceph概况
  10. http://www.easyui.info/archives/396.html