निम्नलिखित पायथन फ़ंक्शन का आउटपुट क्या होगा?
What will be the output of the following Python function?
complex(1+2j)
A
Error
B
1
C
2j
D
1+2j
Explanation
The function complex() in Python is used to create a complex number.
- The argument passed to
complex()is expected to be in the form of two parts: a real part and an imaginary part. - In the given code,
complex(1+2j)is actually passing a complex number1+2jas an argument to thecomplex()function.
When you call complex(1+2j), it will return the same complex number, i.e., 1+2j, as the argument is already a valid complex number.
Answer: (D) 1+2j.
Correct Answer: D) 1+2j