Here is my code.
How do I execute the print_point line? Edited to work. Thank you
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def distance_from_origin(self):
return ((self.x **2) + (self.y **2)) **.5
def print_point(p):
print '(%s, %s)' % (str(p.x), str(p.y))
Here is what I type into the shell after running module:
p = Point(5,2)
p.x
5
p.y
2
p.distance_from_origin()
5.385164807134504
p.print_point(p)
Traceback (most recent call last):
File "<pyshell#196>", line 1, in <module>
p.print_point(p)
TypeError: print_point() takes exactly 1 argument (2 given)
selfright indistance_from_origin, but notprint_point. (Also, check your indentation: thedefs should be indented.)