Python
15 Best Online Python Courses Free & Paid (2021 Update)
The following best online Python courses will help you to learn Python programming from home....
Python abs() is a built-in function available with the standard library of python. It returns the absolute value for the given number. Absolute value of a number is the value without considering its sign. The number can be integer, floating point number or complex number. If the given number is complex, then it will return its magnitude.
abs(value)
The input value to be given to abs() to get the absolute value. It can be an integer, a float, or a complex number.
It will return the absolute value for the given number.
To get the absolute value of an integer and float number check this code:
# testing abs() for an integer and float
int_num = -25
float_num = -10.50
print("The absolute value of an integer number is:", abs(int_num))
print("The absolute value of a float number is:", abs(float_num))
Output:
The absolute value of an integer number is: 25 The absolute value of a float number is: 10.5
To get absolute value of complex number
# testing abs() for a complex number
complex_num = (3+10j)
print("The magnitude of the complex number is:", abs(complex_num))
Output:
The magnitude of the complex number is: 10.44030650891055
The following best online Python courses will help you to learn Python programming from home....
$20.20 $9.99 for today 4.5 (129 ratings) Key Highlights of Python Tutorial PDF 211+ pages eBook...
What are Conditional Statements in Python? Conditional Statement in Python perform different...
What is Python? Python is a high level object-oriented, programming language. It has built-in data...
Python Rename File Python rename() file is a method used to rename a file or a directory in Python...
In Python everything is object and string are an object too. Python string can be created simply...