Vidyalelo
Python · Q33

MCQs for Python Data Types and Numeric Types Chapter

Programming · Python · question 33

Q33

What is the result of abs(3 + 4j) ?

A.
3
B.
4
C.
5
Answer
D.
7

Answer: Option C

Solution

Answer: Option C
Solution:
In Python, the abs() function returns the magnitude (modulus) of a complex number.

A complex number is written in the form a + bj, where a is the real part and b is the imaginary part.

The magnitude of a complex number is calculated using the formula √(a² + b²).

For the complex number 3 + 4j:

Real part = 3
Imaginary part = 4

Magnitude = √(3² + 4²) = √(9 + 16) = √25 = 5.

Therefore, abs(3 + 4j) returns 5.

Hence, the correct answer is Option C: 5.