LearnFrenzy
Sign in Take a free test

Variables and Data Types · Predict the Output · Question 12

Parts of a complex number Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What is the output of the following Python program?

main.py
z = 3 + 4j
print(z.real, z.imag, abs(z), z * 1j)
  • A 3.0 4.0 5.0 (-4+3j) Correct
  • B 3 4 5 (3+4j)
  • C 3.0 4.0 7.0 (-4+3j)
  • D 3.0 4.0 5.0 (4-3j)
Correct Answer: Option A

The parts are floats. abs(3 + 4j) = √(9 + 16) = 5.0, and (3 + 4j) × j = 3j + 4j² = -4 + 3j.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links