In [8]:
class emp:
cc='IBM' ####attribute ###class variable
def __init__(self,name,dept): ### contructor or init method
[Link]=name
[Link]=dept
def data(self):
print(f'Employee Name is {[Link]}') ####contructor attaributes
print(f'Employee Dept is {[Link]}')
print(f'Company Name is {[Link]}') ### class variable
x=emp('Arun', 'IT')
[Link]='HR' ###modify the variable
print([Link])
[Link]()
HR
Employee Name is Arun
Employee Dept is HR
Company Name is IBM
In [10]:
class human:
def __init__(self, name, age):
[Link]=name
[Link]=age
def h_data(self):
print(f'Name is {[Link]}\nAge is {[Link]}')
obj1=human('arun', '30')
[Link]=19
print([Link])
obj1.h_data()
19
Name is arun
Age is 19
In [22]:
class emp:
loc='HYD' ####attribute ###class variable
def __init__(self, emp_c): ### contructor or init method ### pass a arguments
name=input("Enter your Name: ") ####taking input from keybaord
dept=input("Enter your Dept: ")
[Link]=name
[Link]=dept
[Link]='Wipro' ##attributes from constructor ##variable from constructor
self.emp_c=emp_c ###pass arguments as a function
self.j_year=2019
def data(self):
print(f'\nEmployee Name is {[Link]}') ####contructor attaributes
print(f'Employee Dept is {[Link]}')
print(f'Company Name is {[Link]}') ### class variable
print(f'Employee code is {self.emp_c}')
print(f'Locatin is {[Link]}') ### call class variable indside function
print(f'Join Year is {self.j_year}')
x=emp(101)
[Link]()
Enter your Name: arun
Enter your Dept: it
Employee Name is arun
Employee Dept is it
Company Name is Wipro
Employee code is 101
Locatin is HYD
Join Year is 2019