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

How to represent complex numbers in python

(*-*)浩
Release: 2019-07-09 10:17:39
Original
35573 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template