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?
- it will print A foo
- it will give an error because foo is not defined
- it will print B foo
- it will print Created B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
