Because for complex numbers abs(number) will return magnitude of Complex Numbers.

Magnitude value will counted as : √x2+y2 = √(3² + 4²) = √(9 + 16) = √(25) = 5.0

So abs with complex number will return magnitude of complex numbers.

for further reference you can use https://www.geeksforgeeks.org/abs-in-python/.

Answer from Aditya on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › abs-in-python
abs() in Python - GeeksforGeeks
August 30, 2024 - The Python abs() function return the absolute value. The absolute value of any number is always positive it removes the negative sign of a number in Python.
🌐
W3Schools
w3schools.com › python › ref_func_abs.asp
Python abs() Function
Python Examples Python Compiler ... value of a number: x = abs(-7.25) Try it Yourself » · The abs() function returns the absolute value of the specified number. abs(n) Return the absolute value of a complex number: x = abs(3+5j) ...
🌐
Tutorialspoint
tutorialspoint.com › python › number_abs.htm
Python 3 - Number abs() Method
The Python abs() function returns the absolute value of a number. In simple words, an absolute value of a number 'x' is calculated as the (positive) distance between x and 0. The abs() function accepts all types of numbers, both real and complex
🌐
Real Python
realpython.com › ref › builtin-functions › abs
abs() | Python’s Built-in Functions – Real Python
Returns a number’s absolute value, which is its distance from zero, regardless of its sign.
🌐
Programiz
programiz.com › python-programming › methods › built-in › abs
Python abs()
print('Absolute value of -20 is:', abs(integer)) #random floating number floating = -30.33 · print('Absolute value of -30.33 is:', abs(floating)) Output · Absolute value of -20 is: 20 Absolute value of -30.33 is: 30.33 · # random complex number complex = (3 - 4j) print('Magnitude of 3 - 4j is:', abs(complex)) Output · Magnitude of 3 - 4j is: 5.0 · Also Read: Pandas abs() ( With Examples) NumPy absolute() ( With Examples) Next Tutorial: Python any() Share on: Did you find this article helpful?
🌐
w3resource
w3resource.com › python › built-in-function › abs.php
Python: abs() function - w3resource
If the argument is a complex number, its magnitude is returned. Syntax: abs(x) Version: (Python 3) Parameter: If x is a complex number function returns it's magnitude. The absolute value of a complex number z = x + yj is ·
🌐
Codecademy
codecademy.com › article › python-absolute-value-tutorial
How to Use the abs() Function in Python (With Examples) | Codecademy
In conclusion, the abs() function in Python is a versatile tool for computing the absolute value of numbers. It ensures that only the magnitude is considered, regardless of sign. Its applications in error handling, distance calculations, financial ...
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-absolute-value-a-quick-tutorial
Python Absolute Value: A Quick Tutorial | DataCamp
April 11, 2024 - The absolute value function allows Python programmers to obtain the magnitude of a number, regardless of its sign, essentially making the number positive. The absolute value function in Python returns the positive distance between that number and zero on a number line.
🌐
Pytut
pytut.com › abs
Python abs() Function - PyTut
The abs() built-in Python function calculates absolute value of a number. It takes one input x. For negative numbers (x < 0) it returns -x. For positive numbers and zero (x >= 0) it returns x. Typical arguments to the abs() function are int or float types. >>> abs(3) 3 >>> abs(-3) 3 >>> abs(0) ...
🌐
Javatpoint
javatpoint.com › python-abs-function
abs() in Python | Python abs() Function with Examples - Javatpoint
abs() in Python | Python abs() Function with Examples on Python, Built in, Functions, abs Function, all Function, bin Function, bool Function, python Functions, new sum Function, bytes Function, new callable Function etc.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Get Absolute Values in Python: abs(), math.fabs() | note.nkmk.me
May 11, 2025 - ... Passing a complex number (complex) to abs() returns its absolute value (also known as its modulus or magnitude) as a float. print(abs(1 + 1j)) # 1.4142135623730951 print(abs(3 + 4j)) # 5.0 print(type(abs(3 + 4j))) # <class 'float'>
🌐
LearnDataSci
learndatasci.com › solutions › python-absolute-value
Python Absolute Value – abs() for real and complex numbers – LearnDataSci
The use of the abs() function has converted the negative numbers into positive ones. For the positive numbers, there has been no change. Remember that the absolute value of a real number refers to its distance from 0 and is known as magnitude. As magnitude is just a distance, it will always be positive. We can also use the abs() function on floats. See below for an example of this: real_number_list = [-4.16, -3.12, 11.88, 16.32] for number in real_number_list: absolute_value = abs(number) print(f'Number: {number}, Absolute Value: {absolute_value}')
🌐
Server Academy
serveracademy.com › blog › python-absolute-value-abs-tutorial
Python Absolute Value Abs() Tutorial - Server Academy
In Python, the simplest way to calculate the absolute value is to use the abs() function. This built-in function returns the absolute value of any number, whether it’s an integer, float, or complex number.
🌐
Python Cheatsheet
pythoncheatsheet.org › builtin › abs
Python abs() built-in function - Python Cheatsheet
The argument may be an integer, ... its magnitude is returned. The abs() function in Python is a built-in function that returns the absolute value of a number....
🌐
Real Python
realpython.com › python-absolute-value
How to Find an Absolute Value in Python – Real Python
June 4, 2025 - The abs() function in Python accepts all numeric data types available, including the lesser-known fractions and decimals. For instance, you can get the absolute value of one-third or minus three-quarters defined as Fraction instances: ... >>> from fractions import Fraction >>> abs(Fraction("1/3")) Fraction(1, 3) >>> abs(Fraction("-3/4")) Fraction(3, 4)
🌐
freeCodeCamp
freecodecamp.org › news › python-absolute-value-python-abs-tutorial
Python Absolute Value – Python abs Tutorial
June 20, 2022 - When a complex number is passed as an argument to the abs() function, the return value is the magnitude of that number. The magnitude of a complex number, such as a+bj, is the number's distance between the origin (0,0) and the point (a,b) in the complex plane. And the magnitude of a complex number is calculated with the help of the Pythagorean theorem, \(\sqrt{a^2 + b^2}\) So, let's take the complex number 3 + 4j for example.
🌐
Scaler
scaler.com › home › topics › python abs() function
Python abs() Function - Scaler topics
December 4, 2023 - The standard Python library has a function abs(), short for "absolute" value. It returns the value given as input without the sign with it, that is, the positive value.
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
The argument may be an integer, ... __abs__(). If the argument is a complex number, its magnitude is returned. ... Return an asynchronous iterator for an asynchronous iterable. Equivalent to calling x.__aiter__(). Note: Unlike iter(), aiter() has no 2-argument variant. Added in version 3.1...
🌐
BeginnersBook
beginnersbook.com › 2019 › 03 › python-abs-function
Python abs() Function with examples
Complex numbers, for example 3+4j, 4+6j etc. # integer number num = -5 print('Absolute value of -5 is:', abs(num)) # floating number fnum = -1.45 print('Absolute value of 1.45 is:', abs(fnum))