Question
Select the result obtained when you run the program below.
class Point:
def __init__(x, y):
self.x = x
self.y = y
origin = Point(0, 0)
origin.x = 12
print(origin.x)
Question
Select the result obtained when you run the program below.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.xcoord) + ", " + str(self.ycoord) + ")"
origin = Point(0, 0)
print(origin)
Question
Select the result obtained when you run the program below.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
origin = Point(0, 0)
print(hasattr(origin, x))
Question
Select all choices that result in the value True
after the following code has been run. There may be more than one correct answer.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
origin = Point(0, 0)
origin.x = 12
other = Point(12, 0)
Question
In the box provided, enter the result obtained when you run the program below.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
origin = Point(0, 0)
new = origin
origin.y = 12
new.x = origin.y + 5
print(origin.x)
Question
Select all choices for the body of the method move_up
such that the completed program will produce (4, 30)
. There may be more than one correct answer.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
def move_up(self, offset):
one = Point(4, 10)
one.move_up(20)
print(one)
Question
Select the result obtained when you run the program below.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
def move_up(self, offset):
self.y = self.y + offset
one = Point(4, 10)
two = one.move_up(20)
print(two.x)
Question
In the box provided, enter the result obtained when you run the program below.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
def between(first, second):
return Point((first.x + second.x) / 2, (first.y + second.y) / 2)
one = Point(4, 10)
two = Point(16, 16)
print(between(one, two).x)
Question
Select all choices that are true concerning making the function between
into a method in the program below. There may be more than one correct answer.
class Point:
def __init__(self, xcoord, ycoord):
self.x = xcoord
self.y = ycoord
def __str__(self):
return "(" + str(self.x) + ", " + str(self.y) + ")"
def between(first, second):
return Point((first.x + second.x) / 2, (first.y + second.y) / 2)
Question
Supposing that the method between
has been created as in the previous question, select the correct syntax for determining the value of the x
attribute of the point between points one
and two
.