Respuesta :

Answer:

Following are the code to this question:

class Point:#defining a class Point

   def __init__(self, x, y):#defining a constructor that takes three parameters  

       self.x = x#use self to hold x variable value

       self.y = y#use self to hold y variable value

   def Reflect_x(self):#defining a method reflect_x that hold object self

       return Point(self.x, (-1) * self.y)#use return keyword that return positive x and negative y value

   def __str__(self):#Use __str__ to convert object value into string  

       return "Point(" + str(self.x) + "," + str(self.y) + ")"#return string value

py = Point(3, 5)#defining a variable py that call class by passing the value  

reflect = py.Reflect_x();#Use variable reflect to hold Reflect_x value

print("P:", py)#print value

print("Reflection about x axis of p:", reflect)#print value

Output:

P: Point(3,5)

Reflection about x axis of p: Point(3,-5)

Explanation:

In the code, a class "Point" is declared, inside the class, a constructor is created that hold three-parameter "self, x, and y", and use a self to hold x and y values.

In the next step, a "Reflect_x" method is defined that uses a class object and converts the x and y values, and in the next step, the str method is used that converts an object value into a string and return its values.

Outside the class, a py variable is defined, that holds Point values and pass into the Reflect_x method, and prints its return values.