6
What is the output of the following code?
class P:
def __str__(self):
return 'Point'
print(P())DiscussEasy
Loading subject content…
Loading practice questions…
What is the output of the following code?
class P:
def __str__(self):
return 'Point'
print(P())What is the output of the following code?
class A:
count = 0
def __init__(self):
A.count += 1
A(); A()
print(A.count)What is the output of the following code?
class Dog:
def __init__(self, name):
self.name = name
def speak(self):
return self.name + ' barks'
print(Dog('Rex').speak())What is the output of the following code?
class T:
def __init__(self):
self.__secret = 1
t = T()
print(hasattr(t, '__secret'), hasattr(t, '_T__secret'))What is the output of the following code?
class C:
count = 0
def __init__(self):
C.count += 1
C(); C(); C()
print(C.count)