math.fabs_带有Python示例的math.fabs()方法
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()方法相关推荐
- math.trunc_带有Python示例的math.trunc()方法
math.trunc Python math.trunc()方法 (Python math.trunc() method) math.trunc() method is a library metho ...
- math.atan2_带有Python示例的math.atan2()方法
math.atan2 Python math.atan2()方法 (Python math.atan2() method) math.atan2() method is a library metho ...
- js math.hypot_带有Python示例的math.hypot()方法
js math.hypot Python math.hypot()方法 (Python math.hypot() method) math.hypot() method is a library me ...
- python math.sinh_带有Python示例的math.sinh()方法
Python math.sinh() 方法 math.sinh()方法是数学模块的一种库方法,用于获取以弧度为单位的给定数字的双曲正弦值,它接受一个数字并返回双曲正弦值. 注意: math.sinh( ...
- np.isfinite_带有Python示例的math.isfinite()方法
np.isfinite Python math.isfinite()方法 (Python math.isfinite() method) math.isfinite() method is a lib ...
- factorial函数_带有Python示例的math.factorial()方法
factorial函数 Python math.factorial()方法 (Python math.factorial() method) math.factorial() method is a ...
- np.copysign_带有Python示例的math.copysign()方法
np.copysign Python math.copysign()方法 (Python math.copysign() method) math.copysign() method is a lib ...
- 带有Python示例的math.sin()方法
Python math.sin()方法 (Python math.sin() method) math.sin() method is a library method of math module, ...
- tf.acos_带有Python示例的math.acos()方法
tf.acos Python math.acos()方法 (Python math.acos() method) math.acos() method is a library method of m ...
最新文章
- Vue.js 是什么
- libpcap-mmap分析(五)
- oracle数据库 spring,oracle spring 连接数据库 报错
- 设置Windows XP自动登录的两种方法
- Python_堆栈和队列
- ubuntu mysql双主热备配置_MySql双主热备配置
- java八大基本类型介绍
- 关于防火墙以及其作用
- 史上首次!个人所得税退税来了!如何退?怎么操作?
- 求1+2!+3!+...+N!的和
- 有一个8位机,采用单总线结构......(计算机组成原理课后习题)
- C++最后一次实验及实验总结
- ECCV 2020开源项目合集 (ECCV 2020 paper list with code/data)
- 淘口令真实url API 返回值说明
- Linux下BMP图片添加水印
- 从零使用强化学习训练AI玩儿游戏(3)——使用Q-learning
- 树莓派3 读取DS18B20 温度
- S3C2440之LCD
- 两台windows内网之间快速复制大量(上百万个)小文件(可用于两台服务器之间)...
- 腾讯、阿里、百度、网易等18家中秋月饼设计盘点!(完整版)