class Cal(object):
def __init__(self, v1, v2):
if isinstance(v1, int):
self.v1 = v1
if isinstance(v2, int):
self.v2 = v2
def add(self):
return self.v1+self.v2
def subtract(self):
return self.v1-self.v2
def setV1(self, v):
if isinstance(v, int):
self.v1 = v
def getV1(self):
return self.v1
class CalMultiply(Cal):
def multiply(self):
return self.v1*self.v2
class CalDivide(CalMultiply):
def divide(self):
return self.v1/self.v2
c1 = CalMultiply(10,10)
print(c1.add())
print(c1.multiply())
c2 = CalDivide(20,10)
print(c2, c2.add())
print(c2, c2.multiply())
print(c2, c2.divide())
Y2xhc3MgQ2FsKG9iamVjdCk6CiAgICBkZWYgX19pbml0X18oc2VsZiwgdjEsIHYyKToKICAgICAgICBpZiBpc2luc3RhbmNlKHYxLCBpbnQpOgogICAgICAgICAgICBzZWxmLnYxID0gdjEKICAgICAgICBpZiBpc2luc3RhbmNlKHYyLCBpbnQpOgogICAgICAgICAgICBzZWxmLnYyID0gdjIKICAgIGRlZiBhZGQoc2VsZik6CiAgICAgICAgcmV0dXJuIHNlbGYudjErc2VsZi52MgogICAgZGVmIHN1YnRyYWN0KHNlbGYpOgogICAgICAgIHJldHVybiBzZWxmLnYxLXNlbGYudjIKICAgIGRlZiBzZXRWMShzZWxmLCB2KToKICAgICAgICBpZiBpc2luc3RhbmNlKHYsIGludCk6CiAgICAgICAgICAgIHNlbGYudjEgPSB2CiAgICBkZWYgZ2V0VjEoc2VsZik6CiAgICAgICAgcmV0dXJuIHNlbGYudjEKY2xhc3MgQ2FsTXVsdGlwbHkoQ2FsKToKICAgIGRlZiBtdWx0aXBseShzZWxmKToKICAgICAgICByZXR1cm4gc2VsZi52MSpzZWxmLnYyCmNsYXNzIENhbERpdmlkZShDYWxNdWx0aXBseSk6CiAgICBkZWYgZGl2aWRlKHNlbGYpOgogICAgICAgIHJldHVybiBzZWxmLnYxL3NlbGYudjIKYzEgPSBDYWxNdWx0aXBseSgxMCwxMCkKcHJpbnQoYzEuYWRkKCkpCnByaW50KGMxLm11bHRpcGx5KCkpCmMyID0gQ2FsRGl2aWRlKDIwLDEwKQpwcmludChjMiwgYzIuYWRkKCkpCnByaW50KGMyLCBjMi5tdWx0aXBseSgpKQpwcmludChjMiwgYzIuZGl2aWRlKCkpCg==