Explanation:
1. Code
print(abs(3+4j))
2. 3 + 4j — Complex Number
In Python, j represents the imaginary unit.
A complex number has the form:
a + bj
Here:
Real part = 3
Imaginary part = 4
So:
3 + 4j
is a complex number.
3. abs() — Finding Magnitude
For a complex number:
abs(a + bj)
calculates its magnitude using:
√(a² + b²)
For 3 + 4j:
√(3² + 4²)
= √(9 + 16)
= √25
= 5
4. print() — Displaying the Result
After calculating:
abs(3+4j)
Python gets:
5.0
Then print() displays it.
5. Final Output
5.0

0 Comments:
Post a Comment