Question OOP-ABS-0063
HardWhat is the output of this code?
from abc import ABC, abstractmethod
class Repo(ABC):
@abstractmethod
def get(self, k): ...
def get_or(self, k, d):
v = self.get(k)
return d if v is None else v
class Mem(Repo):
def __init__(self): self.d = {"a": 1}
def get(self, k): return self.d.get(k)
r = Mem()
print(r.get_or("a", 0), r.get_or("b", 0), (r, Repo))
- A.
1 None True
- B.
TypeError
- C.
Sign up free to see the answer and a step-by-step explanation.