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. Vue.js 是什么
  2. libpcap-mmap分析(五)
  3. oracle数据库 spring,oracle spring 连接数据库 报错
  4. 设置Windows XP自动登录的两种方法
  5. Python_堆栈和队列
  6. ubuntu mysql双主热备配置_MySql双主热备配置
  7. java八大基本类型介绍
  8. 关于防火墙以及其作用
  9. 史上首次!个人所得税退税来了!如何退?怎么操作?
  10. 求1+2!+3!+...+N!的和
  11. 有一个8位机,采用单总线结构......(计算机组成原理课后习题)
  12. C++最后一次实验及实验总结
  13. ECCV 2020开源项目合集 (ECCV 2020 paper list with code/data)
  14. 淘口令真实url API 返回值说明
  15. Linux下BMP图片添加水印
  16. 从零使用强化学习训练AI玩儿游戏(3)——使用Q-learning
  17. 树莓派3 读取DS18B20 温度
  18. S3C2440之LCD
  19. 两台windows内网之间快速复制大量(上百万个)小文件(可用于两台服务器之间)...
  20. 腾讯、阿里、百度、网易等18家中秋月饼设计盘点!(完整版)

热门文章

  1. html5语义化标签 加粗,html5标签 H5标签
  2. python 教学_「Python基础」一次就装好Python手把手装到好
  3. Redis(九):Redis特殊类型之geospatial
  4. Redis(四):String字符串数据类型详解
  5. 【动态规划】完全背包问题
  6. 中缀表达式转换成后缀表达式(只适用于加减乘除运算)
  7. 正则表达式知识详解(转自晴天碧日)
  8. 2017-2018-1 20155229 《信息安全系统设计基础》第十四周学习总结
  9. 聊聊全站HTTPS带来的技术挑战
  10. eclispe快捷键