class cal:
def __init__(self, one, two):
self.one=one
self.two=two
def add(self):
result=self.one+self.two
return result
def mul(self):
result=self.one*self.two
return result
def sub(self):
result=self.one-self.two
return result
def div(self):
result=self.one/self.two
return result
class more(cal):
def pow(self):`result=self.one**self.two
return result
Here, I would like to know if power
of class more
can be changed to ___init_
and how it changes to change it.
I might have misunderstood the question I wonder if you are talking about the following.
class cal:
def __init__(self, one, two):
self.one=one
self.two=two
def add(self):
result=self.one+self.two
return result
def mul(self):
result=self.one*self.two
return result
def sub(self):
result=self.one-self.two
return result
def div(self):
result=self.one/self.two
return result
class more(cal):
def __init__(self, one, two):
self.one = one
self.two = two
def pow(self):
result=self.one**self.two
return result
a = more(3,3)
print(a.add()) # 6
print(a.pow()) # 27
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
546 Understanding How to Configure Google API Key
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
549 PHP ssh2_scp_send fails to send files as intended
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.