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

R is not a simple programming language, and it does better on reading excel files than python

R is not a simple programming language, and it does better on reading excel files than python . tried to read excel files to python and R. i...