Python Program to rotate a complex no by 180

Viewed 18

I want to rotate a complex no by 180° and this code is in my textbook but it gives me a error everytime

import matplotlib.pyplot as plt
x = 2 + 4j
plt.scatter (x.real, x.imag, color='red')
plt.scatter (-1 x.real, -1 x.imag, color = 'blue')
plt.show ()

Desired Output I want output something like that

1 Answers

You can use either -

plt.scatter (-1 * x.real, -1 * x.imag, color = 'blue')

or simply -

plt.scatter (-x.real, -x.imag, color = 'blue')
Related