fork download
  1. class Arithmetics:
  2. def __init__(self,n1,n2):
  3. self.first=n1
  4. self.second=n2
  5. def sub (self,other):
  6. print('{}+{}i'.format(self.x+other.x,self.y+other.y))
  7. def mult (self,other):
  8. print('{}+{}i'.format(self.x*other.x-self.y*other.y,self.x*other.x+self.y*other.y))
  9. def add (self,other):
  10. print('{}+{}i'.format(self.x+other.x,self.y+other.y))
  11. def dev (self,other):
  12. print('{}+{}i'.format((self.x*other.x+self.y*other.y)/(other.x**2+other.y**2),(self.x*other.x-self.y*other.y)/(other.x**2+other.y**2)))
  13.  
  14. c1 = Arithmetics(1,2)
  15. c2 = Arithmetics(3,4)
  16. print(c1-c2)
  17. print(c1*c2)
  18. print(c1+c2)
  19. print(c1/c2)
  20.  
Runtime error #stdin #stdout #stderr 0.01s 7316KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 16, in <module>
TypeError: unsupported operand type(s) for -: 'instance' and 'instance'