It is a basic question. I have written the following code:
class Point:
def __init__(self,x=0,y=0):
self.x=x
self.y=y
def __str__(self):
return '({0} , {1})'.format(self.x,self.y)
def reflect_x(self):
return Point(self.x,-self.y)
p1=Point(3,4)
p2=p1.reflect_x
print(str(p1),str(p2))
print(type(p1),type(p2))
Here type of p1
and type of p2
are different. I just want p2
as a point which is the reflected point of p1
from x-axis. How can I do it?