Learn Before
Code
Sample code for abs() function
a = 4 b = abs(a) print("Absolute value of a is",b)
Output
Absolute value of a is 4
a = -4 b = abs(a) print("Absolute value of a is",b)
Output
Absolute value of a is 4
a = -4.1 b = abs(a) print("Absolute value of a is",b)
Output
Absolute value of a is 4.1
a = 4.1 b = abs(a) print("Absolute value of a is",b)
Output
Absolute value of a is 4.1
a = complex(4,3) b = abs(a) print("Absolute value of a is",b)// returns magnitude of the complex number
Output
Absolute value of a is 5.0
0
0
Updated 2021-02-03
Tags
Python Programming Language
Data Science