Question: Explain correct answer 1. I have a class Robot that takes a name as an argument to the init function. What is the proper way

Explain correct answer

1. I have a class Robot that takes a name as an argument to the init function. What is the proper way to call this when creating an instance?

A. r2d2 = Robot("R2")

B. r2d2 = Robot(self,"R2")

C. r2d2 = Robot()

D. r2d2 = Robot.__init__("R2")

2.

class A:

def __init__(self):

print "Created A"

def foo():

print "A foo"

class B(A):

def __init__(self):

print "Created B"

If I have an instance of B and call the foo function through it, what will happen?

  1. it will print A foo
  2. it will give an error because foo is not defined
  3. it will print B foo
  4. it will print Created B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!