4.3.5.Graded Quiz: Objects and Classes - sj50179/IBM-Data-Science-Professional-Certificate GitHub Wiki

LATEST SUBMISSION GRADE 100%

Question 1Consider the class Points, what are the data attributes?

class Point(object):

  def __init__(self,x,y):

    self.x=x
    self.y=y

  def print_point(self):

    print('x=',self.x,'y=',self.y)
  • self.x self.y

  • init

  • print_point

Correct

Question 2

What is the result of running the following lines of code ?

class Points(object):
  def __init__(self,x,y):

    self.x=x
    self.y=y

  def print_point(self):

    print('x=',self.x,' y=',self.y)

p1=Points(1,2)
p1.print_point()

  • x=1;

  • x=1 y=2

  • y=2

correct

Question 3

What is the result of running the following lines of code ?

class Points(object):

  def __init__(self,x,y):

    self.x=x
    self.y=y

  def print_point(self):

    print('x=',self.x,' y=',self.y)

p2=Points(1,2)

p2.x='A'

p2.print_point()
  • x= 1 y=2

  • x= A y=2

  • x=A, y=B

correct