Monday, 23 July 2018

11-C Prog-9 Write Program to find absolute value for integer, real and Complex Numbers



# Python code to illustrate 
# abs() built-in function

# floating point number
float = -54.26
print('Absolute value of integer is:', abs(float))

# An integer
int = -94
print('Absolute value of float is:', abs(int))

# A complex number
complex = (3 - 4j)
print('Absolute value or Magnitude of complex is:', abs(complex))
Example:
Absolute value of integer is: 54.26
Absolute value of float is: 94
Absolute value or Magnitude of complex is: 5.0

No comments:

Post a Comment