“Python3 func number abs”的版本间差异

本页内容
下一节: Python_func_dict
(文本替换 - 替换“example_start”为“”)
Neo讨论 | 贡献
无编辑摘要
 
第1行: 第1行:
{{DISPLAYTITLE:abs(x)}}[[Category:python3 number|1]]
{{DISPLAYTITLE:abs()}}[[Category:python3 built in functions|1]]
= Python3 abs() 函数 =
= Python3 abs() 函数 =


第25行: 第25行:
以下展示了使用 abs() 方法的实例:
以下展示了使用 abs() 方法的实例:


<sample title="" desc="" lang="python" hererun="1">  
<sample title="" desc="" lang="python" hererun="1">
#!/usr/bin/python3
#!/usr/bin/python3


第32行: 第32行:
print ("abs(100.10) : ", abs(100.10))
print ("abs(100.10) : ", abs(100.10))


  </sample>
</sample>
以上实例运行后输出结果为:
以上实例运行后输出结果为:



2022年8月17日 (三) 21:48的最新版本

Python3 abs() 函数

Python3 数字

描述

abs() 函数返回数字的绝对值。

语法

以下是 abs() 方法的语法:


示例

abs( x )

参数

  • x -- 数值表达式,可以是整数,浮点数,复数。

返回值

函数返回 x(数字)的绝对值,如果参数是一个复数,则返回它的大小。

以下展示了使用 abs() 方法的实例:


示例

#!/usr/bin/python3

print ("abs(-40) : ", abs(-40))

print ("abs(100.10) : ", abs(100.10))

以上实例运行后输出结果为:


示例

abs(-40) :  40
abs(100.10) :  100.1

相关文章:Python fabs() 与 abs() 区别

Python3 数字

下一节: Python_func_dict
此页面最后编辑于2022年8月17日 (星期三) 21:48。