Does anyone know how to add n1 and n2 using classes? the output should be an imaginary number.
The first arguements in n1 and n2 are real, the second arguements are imaginary. I want to add the real numbers of n1 and n2 together while also adding the imaginary numbers of n1 and n2.
add this function to Complex
def __add__(self, x):
y = # do the calculation here
return y
Then what does x do?
something like y = x.real + self.real
or self.imag
I didn’t really want to fully give exactly how to add imaginate numbers
it’s the same thing as normal numbers iirc
I thougth I already gave this answer but less … other stuff
wdym? You didn’t provide any code, or tell OP how to make the __add__
method or anything
I think that was because this might have been for a school assignment
But he’s in main.py
, not Student.py
, so I thought he is a teacher
It doesn’t seem like that when you look at their replit profile.
Also, they specifically asked how to add two class instances. It seems like they already knew the details on how exactly to mathematically add two complex numbers.
well normally I just give a small amount of stuff then add on it if they want more info since an info dump causes people not to read it but feeding it slowly and giving engaging convos makes it feel more fufilling
umm
??? wth
I need the THIS emoji/reaction here
oh nvm I thought someone else posted that code