Home >Backend Development >Python Tutorial >How to represent complex numbers in python

How to represent complex numbers in python

(*-*)浩
(*-*)浩Original
2019-06-28 10:18:5135566browse

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.

How to represent complex numbers in python

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:When did python appear?Next article:When did python appear?