Advertisement
piffy

unittest Punto

Jan 19th, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | Source Code | 0 0
  1. import math
  2.  
  3. class Punto:
  4.     def __init__(self,x,y):
  5.         self._x = x
  6.         self._y = x
  7.  
  8.     def x(self):
  9.         return self._x
  10.  
  11.     def y(self):
  12.         return self._y
  13.  
  14.     def distanza_da(self, p):
  15.         dx = self.x() - self.x()
  16.         dy = self.y() - self.y()
  17.         return math.sqrt(dx * dx + dy * dy)
  18.  
  19.     def __str__(self):
  20.         return f"({self._x}, {self._y})"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement