Question on 2D point problem

I have a question on why the below program throws an error:

import math

class Point2D:
    
    def __init__(self, x, y):
        self.__x = x
        self.__y = y
        
    def calculate_distance(self, other):
        dx = self.__x - other.x
        dy = self.__y - other.y
        return math.sqrt(dx*dx + dy*dy)
    
point1 = Point2D(3,4)
point2 = Point2D(9,5)

distance = point1.calculate_distance(point2)

print(distance)

Error:

AttributeError Traceback (most recent call last)
in
16 point2 = Point2D(9,5)
17
—> 18 distance = point1.calculate_distance(point2)
19
20 print(distance)

in calculate_distance(self, other)
9
10 def calculate_distance(self, other):
—> 11 dx = self.__x - other.x
12 dy = self.__y - other.y
13 return math.sqrt(dxdx + dydy)

AttributeError: ‘Point2D’ object has no attribute ‘x’

Hi @sathish.sugavanam1,

Why do you need the double underscore in self.x and self.y? Please attach the mission link as per these guidelines so we know the particular mission you are referring to. Thanks!

This is the mission link:
https://app.dataquest.io/m/1000352/object-oriented-python-practice-problems/3/2-d-points

I wanted those two variables to be PRIVATE. Please clarify if my approach in incorrect or python behaves in this way