In [18]:
class car:
def __init__(self, md, m): ####init method or constructor
self.__car_model = md
self.__car_m = m
def model(self):
print(f"we have 10 {self.__car_model} model in store")
print(f"we have 10 {self.__car_m} model in store")
obj1 = car('hundai', 'muruti')
[Link]()
print('-'*56)
car('hundai', 'muruti').model()
we have 10 hundai model in store
we have 10 muruti model in store
--------------------------------------------------------
we have 10 hundai model in store
we have 10 muruti model in store
In [2]:
class car:
#car_model=' ' ####these are know as attributes or local variable or
#car_m=' ' ###opject orients varaiable
def __init__(self, md, m): ####init method or constructor
self.car_model = md
self.car_m = m
def model(self):
print(f"we have 10 {self.car_model} model in store")
print(f"we have 10 {self.car_m} model in store")
a=car('muriti', 'hundai')
[Link]()
we have 10 muriti model in store
we have 10 hundai model in store
In [2]:
class car:
def model(self):
print(f"we have 10 model in store")
b=car()
[Link]()
we have 10 model in store
In [5]:
class car:
def __init__(self, md): ####init method or constructor
self.car_model = md
def model(self):
print(f"we have 10 {self.car_model} model in store")
a=car('muriti')
[Link]()
we have 10 muriti model in store
In [17]:
class emp:
cc='IBM' ####attribute ###class variable
def __init__(self,name,dept): ### contructor or init method
self.n=name
self.d=dept
def data(self):
print(f'Employee Name is {self.n}') ####contructor attaributes
print(f'Employee Dept is {self.d}')
print(f'Company Name is {[Link]}') ### class variable
x=emp('Arun', 'IT')
[Link]()
Employee Name is Arun
Employee Dept is IT
Company Name is IBM
In [19]:
n='arun'
d='dept'
c='IBM'
def data(name,dept):
print(f'Employee Name is {name}')
print(f'Employee Dept is {dept}')
print(f'Company Name is {c}')
data(n,d)
Employee Name is arun
Employee Dept is dept
Company Name is IBM
In [2]:
class emp:
cc='IBM' ###class variable
def __init__(self,name,dept): ### contructor or init method
self.n=name
self.d=dept
def data(self):
print(f'Employee Name is {self.n}') ####contructor attaributes
print(f'Employee Dept is {self.d}')
print(f'Company Name is {[Link]}') ### class variable
x=emp('Arun', 'IT')
[Link]='HR'
print([Link])
[Link]()
HR
Employee Name is Arun
Employee Dept is IT
Company Name is IBM
In [ ]: