Monday, 24 January 2022

Write a python script to define the class person having members name, address. Create a subclass called Employee with members staffed salary. Create 'n' objects of the Employee class and display all the details of the employee.

Slip 18 Q 2

CODE:

class person:
    def __init__(self,name,address):
        self.empname=name
        self.address=address
       
    def display(self):
        print('name : {}\taddress : {}\tsalary : {}'.format(self.empname,
        self.address,a.getsalary()))
   
class employee(person):
    def __init__(self, name, address,salary):
        super().__init__(name, address)
        self.salary=salary
       
    def getsalary(self):
        return self.salary
name1=input('enter name : ')
address=input('enter address : ')
salary=int(input('enter salary : '))
a=employee(name1,address,salary)
a.display()

OUTPUT:




No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...