- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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)

- Related Questions & Answers
- Complex Numbers in Python?
- How to Plot Complex Numbers in Python?
- How does linear regression work with Tensorflow in Python?
- Python program for Complex Numbers
- How does BackReference work with Python Regular Expression with Unicode?
- How can we use complex numbers in Python?
- How does Python while loop work?
- How does mkdir -p 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?
- How does ++ and -- operators work in Python?
- How does tuple comparison work in Python?

Advertisements