0
0
NumPydata~5 mins

Complex number type in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a complex number in numpy?
A complex number in numpy has a real part and an imaginary part. It is represented as a + bj, where a is the real part and b is the imaginary part.
Click to reveal answer
beginner
How do you create a complex number array in numpy?
You can create a complex number array using numpy.array with complex values, for example: np.array([1+2j, 3+4j]).
Click to reveal answer
intermediate
What numpy data types represent complex numbers?
Numpy uses complex64 and complex128 to represent complex numbers. complex64 uses 32 bits for real and 32 bits for imaginary parts, while complex128 uses 64 bits for real and 64 bits for imaginary parts.
Click to reveal answer
beginner
How can you access the real and imaginary parts of a numpy complex array?
Use the .real attribute to get the real parts and .imag attribute to get the imaginary parts of a numpy complex array.
Click to reveal answer
intermediate
Why are complex numbers useful in data science?
Complex numbers help in fields like signal processing, quantum computing, and electrical engineering where data has both magnitude and phase information.
Click to reveal answer
Which numpy data type is used for complex numbers with 64-bit real and imaginary parts?
Acomplex64
Bcomplex128
Cfloat64
Dint64
How do you get the imaginary part of a numpy complex array named z?
Az.imag
Bz.real
Cimag(z)
Dz.imaginary
What does the complex number 3 + 4j represent?
AMagnitude 3, phase 4
BReal part 4, imaginary part 3
CImaginary part 3, real part 4
DReal part 3, imaginary part 4
Which numpy function can create an array of complex numbers?
Anp.array
Bnp.complex
Cnp.complex_array
Dnp.complex64
Why might data scientists use complex numbers?
ATo store only real numbers
BTo speed up sorting algorithms
CTo represent data with magnitude and phase
DTo reduce memory usage
Explain how to create and access parts of a complex number array in numpy.
Think about how you write complex numbers and how numpy stores them.
You got /4 concepts.
    Describe the difference between complex64 and complex128 in numpy.
    Consider how many bits are used for each part.
    You got /4 concepts.