# -*- coding: utf-8 -*-
"""
day 22:
Topic : classes
@author: anil
class addition():
def __init__(self,a,b):
self.a=a
self.b=b
#print("self",self.a,self.b)
def add(self):
c= self.a + self.b
print("self",self.a,self.b)
return c
if __name__ == "__main__":
a=addition(10,20)
a.add()
class addition():
def __init__(self,a,b):
self.a=a
self.b=b
#print("self",self.a,self.b)
def add(self):
c= self.a + self.b
print("self",self.a,self.b,c)
return c
if __name__ == "__main__":
a=addition(10,20)
a.add()
#print(addition(300,40))
class addition():
def __init__(self,a,b):
self.a=a
self.b=b
#print("self",self.a,self.b)
def add(self):
c= self.a + self.b
print("self",self.a,self.b,c)
return c
def sub(self):
c= self.a - self.b
print("self",self.a,self.b,c)
return c
if __name__ == "__main__":
a=addition(10,20)
a.sub()
#print(addition(300,40))
class addition():
def add(self):
print("this is add method")
if __name__ == "__main__":
a=addition()
a.add()
#print(addition(300,40))
class engine():
#print("this is engine")
def piston():
print("piston")
class carbody():
#print("this is carbody")
def seats():
print("seats")
engine.piston()
carbody.seats()
class engine():
#print("this is engine")
def piston():
print("piston")
class carbody():
#print("this is carbody")
def seats():
print("seats")
engine.piston()
carbody.seats()
"""
class engine():
def __init__(self):
print("this is engine")
def piston():
print("piston")
class carbody(engine):
print("this is carbody")
def seats():
print("seats")
carbody()
No comments:
Post a Comment