1
Loading subject content…
Loading subject content…
Loading practice questions…
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 A:
def hello(self):
return 'A'
class B(A):
def hello(self):
return 'B' + super().hello()
print(B().hello())What is the output of the following code?
class Animal:
def sound(self):
return 'generic'
class Cat(Animal):
def sound(self):
return 'meow'
print(Cat().sound(), Animal().sound())What is the output of the following code?
class Temp:
def __init__(self, c):
self._c = c
@property
def f(self):
return self._c * 9 / 5 + 32
print(Temp(100).f)