1) Single inheritance:
- If one base class and one derived class in a program called “Single inheritance”.
- class a://Base classclass b: public a//Derived classObject creation:object_name=Derived_class_name();object_name.function(parameter list);
class employee:#base class
def get_data(self):#All function should have the self keyword for joining other fun
id=input("Enter employee id:")
name=input("Enter employee name:")
depart=input("Enter employee department:")
sal=int(input("Enter basic salary:"))
return id,name,depart,sal
def display(self,id,name,depart,sal):
print("\tEmployee details")
print("ID :",id)
print("Name:",name)
print("Department :",depart)
print("Basic Salary : ",sal)
class salary_cal(employee):#derived class
def sal_cal(self,sal):
if sal>=15000:
sal+=5000
print("Increased salary:5000")
print("Net salary:",sal)
elif sal>=1000 and sal<15000:
sal+=3000
print("Increased salary:3000")
print("Net salary:",sal)
else:
sal+=1000
print("Increased salary:1000")
print("Net salary:",sal)
#Object creation
emp=salary_cal()
empno,ename,deptno,sal=emp.get_data()
emp.display(empno,ename,deptno,sal)
emp.sal_cal(sal)
Thank you for sharing an amazing & wonderful blog. This content is very useful, informative and valuable in order to enhance knowledge. Keep sharing this type of content with us & keep updating us with new blogs. Apart from this, if anyone who wants to join the Python Advanced training institute in Delhi, can contact 9311002620 or visit our website-
ReplyDeletehttps://www.htsindia.com/Courses/python/online-python-training-institute