How To find Absolute value of a number in Python

How To find Absolute value of a number in Python

In this, we discuss how to find the Absolute value of a number using Python Programming.

abs () parameters


The abs () method takes the same argument:

num - The number to which the absolute value must be returned. The number can be:

Integer
Floating number
Complex number

Python Abs ()


Python program to find the absolute value of a number
The absolute value of the abs () number is integer, floating and complex number.

int = integer value is returned
For float = float value is returned
Complex = the magnitude of the number is returned

How To find Absolute value of a number in Python

Python Code:

int = -49
print("absolute value of integer is:", abs(int))
complex = 3-4j
print("absolute value of complex number is:", abs(complex))
float = -4.6
print("absolute value of float integer is:", abs(float))
Output:
absolute value of integer is: 49
absolute value of complex number is: 5.0
absolute value of float integer is: 4.6


Recommended Post:
Python Program to check vowel or Consonant
Program to check character is alphabet or not in Python
Python to check whether the year is leap or not
Python to check if number is Positive, Negative or 0
Python Program to solve Quadratic equation
Program to generate Random numbers in Python
Program to swap two numbers in Python
Program to Add two numbers in Python
Python to convert decimal to binary, octal and hexadecimal
Python Program to find large number among three numbers