Home >Backend Development >Python Tutorial >How to represent complex numbers in python
A complex number is composed of a real number and an imaginary number, expressed as: x yj A complex number is a pair of ordered floating point numbers (x, y), where x is the real part and y is the imaginary part.
Concepts about plural numbers in Python language: Recommended learning: Python video tutorial)
1. Imaginary numbers cannot exist alone. They always form a complex number together with a real part with a value of 0.0
2. A complex number consists of a real part and an imaginary part
3. Represents a complex number Syntax: real imagej
4. The real part and the imaginary part are both floating point numbers
5. The imaginary part must have the suffix j or J
#coding=utf8 aa=123-12j print aa.real # output 实数部分 123.0 print aa.imag # output虚数部分 -12.0
More Python related technical articles, Please visit the Python Tutorial column to learn!
The above is the detailed content of How to represent complex numbers in python. For more information, please follow other related articles on the PHP Chinese website!