Python Practice Lab
easyUnit 2 · Data Types: int, float, complex

P5. Complex Number Details

Data Types: int, float, complex

Read a complex number with complex(input()) and print its type name, real part, imaginary part, conjugate and magnitude.

Input Format

  • Line 1: a complex number written as a+bj or a-bj, with no spaces

Output Format

  • Line 1: Type: complex (use type(z).__name__)
  • Line 2: Real: <z.real>
  • Line 3: Imaginary: <z.imag>
  • Line 4: Conjugate: <z.conjugate()>
  • Line 5: Magnitude: <abs(z)> rounded to 2 decimal places

Constraints

  • The real and imaginary parts are non-zero numbers between -1000 and 1000

Sample Test Cases

Sample 1
Input
3+4j
Output
Type: complex
Real: 3.0
Imaginary: 4.0
Conjugate: (3-4j)
Magnitude: 5.00
Sample 2
Input
-2.5-6j
Output
Type: complex
Real: -2.5
Imaginary: -6.0
Conjugate: (-2.5+6j)
Magnitude: 6.50

Submitting checks 2 sample cases and 4 hidden test cases.

Hints

Saved
Custom 1

This is your own input, so Run will show what your program prints but can't say whether it's correct.