ezoic

Thursday, January 26, 2017

Another Python class example

class Point:
     def __init__(self, a,b):
          self.x=a
          self.y=b
    def  distance_from_origin(self):
         return ((self.x)**2+(self.y)**2)**0.5


d=Point(3,4)

print d.distance_from_origin()

output:

5.0






No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...