- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does modulus work with complex numbers in Python?
Floor and modulus operators (// and % respectively) are not allowed to be used on complex number in Python 3.x. However, these operations are defined for complex numbers in Python 2.7.x
>>> x=9+2j >>> y=2+1j >>> x%y Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> x%y TypeError: can't mod complex numbers.
>>> x=9+2j >>> y=2+1j >>> x%y (1-2j)
Modulus of complex number operands returns their floor division multiplied by denominator
>>> x-(x//y)*y (1-2j)
- Complex Numbers in Python?
- How does linear regression work with Tensorflow in Python?
- How to Plot Complex Numbers in Python?
- How does Python while loop work?
- Python program for Complex Numbers
- How does tuple comparison work in Python?
- How does mkdir -p work in Python?
- How does ++ and -- operators work in Python?
- How does garbage collection work in Python?
- How does class inheritance work in Python?
- How does issubclass() function work in Python?
- How does isinstance() function work in Python?
- How does Overloading Operators work in Python?
- Modulus of Negative Numbers in C
- How can we use complex numbers in Python?