Learn about Absolute Value in Python for Complex Number in the below code example. Also, refer the comments in the code snippet to get a detailed view about what’s actually happening.
Absolute Value in Python for Complex Number
# Program to find absolute value of complex number # input from user num = complex(input('Enter a complex number: ')) # print result print('Magnitude of complex number is =',abs(num))
Enter a complex number: 1+3j
Magnitude of complex number is = 3.162
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : abs() in Python for Floating Number