[12]Consider the following:
class Point():
# A method defining how to create a point:
def __init__(self,x,y):
self.x=y
self.y=y
# ways to represent the objects as string
def __str__(self):
return f”({self.x},{self.y})”
a_point=Point(2,3)
print(a_point)
The code above implements a class named 'Point' representing points on a cartesian plane. What is the purpose of the "self" keyword when defining an instance or calling instance methods?
a. self refers to the instance whose method was called.
b. self refers to the class that was inherited from to create the object using self.
c. self means that no other arguments are required to be passed into the method.
d. There is no real purpose for the self method; it's just historic computer science jargon that Python keeps to stay consistent with other programming languages.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here