Python3 abs() 函数

Python 3 教程 · 2019-02-05 11:58:35

描述

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() 区别

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Programming Concurrency on the JVM

Programming Concurrency on the JVM

Venkat Subramaniam / The Pragmatic Bookshelf / 2011-6-1 / USD 35.00

Concurrency on the Java platform has evolved, from the synchronization model of JDK to software transactional memory (STM) and actor-based concurrency. This book is the first to show you all these con......一起来看看 《Programming Concurrency on the JVM》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具