Problem 38 Quadratic equation

Back to General discussions forum

usherjosh     2019-12-05 21:19:11

I am doing this in python. My code is correct and i get the right aswer the only difference I see is that in python it outputs j for the imaginary part not i. how do i fix this?

output: 2 -6; 0 -4; 4+6i 4-6i; -8+10i -8-10i; 10+6i 10-6i; -9 -10; 4 -9; 8+4i 8-4i; 8+10i 8-10i; -4+3i -4-3i; 9 7; 9 8; 1 -1; 7 3; 9+7i 9-7i; 9 -5 my output:2 -6; 0 -4; 4+6j 4-6j; -8+10j -8-10j; 10+6j 10-6j; -9 -10; 4 -9; 8+4j 8-4j; 8+10j 8-10j; -4+3j -4-3j; 9 7; 9 8; 1 -1; 7 3; 9+7j 9-7j; 9 -5

minnesnowtan     2019-12-07 00:27:42

One option would be to convert the complex numbers to strings and then reformat the strings, perhaps using the replace() method.
Note:

x = 9+7j
x
(9+7j)
y = str(x)
y
'(9+7j)' <-- reformat this

usherjosh     2019-12-09 15:20:22

that worked. Can't believe I didn't think of that

Please login and solve 5 problems to be able to post at forum