Advertisement
Space-G

Classes Homework

Feb 17th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import math
  2.  
  3. class position():
  4.     def __init__(self, x, y):
  5.         self.x = x
  6.         self.y = y
  7.  
  8.     def distance_from_origin(self):
  9.         return math.sqrt((self.x * self.x) + (self.y * self.y))
  10.  
  11.     def __str__(self):
  12.         return "(" + self.x + ", " + self.y + ")"
  13.  
  14.     def __eq__(self, other):
  15.         return (self.x == other.x and self.y == other.y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement