Employee Salary

Employee Salary

Write Python script for the following:                                                                                 

Create a class Employee with three instance variables named: employee_id,  employee_name and basic_pay.  In this, employee id and name are string values and basic pay is a float value.   This class is also contains a member function ‘calculate_net_salary()’  –  this method should calculate and return the net salary of employees. 

The net salary should be calculated using the formula:  net salary=(basic pay+DA+TA+HRA)-PF


DA is 10% of basic pay.

TA is 5% of basic pay.

HRA is 8% of basic pay.

PF is 10% of basic pay.

Get employee id, name and basic pay from the user and store those values into the variables; eid, ename and basic_pay respectively. 

Create an object for the ‘Employee’ class by invoking a parameterized constructor with three arguments: employee id, name and basic pay. The object name should be ‘emp_obj’.   Finally, display the id, name and net salary of the employee as shown in the sample output.

Refer the sample input and output statements for more clarifications.


Strictly follow the naming conventions for variable objects and functions as specified in the problem description.

Sample Input:

Enter the employee id: E101

Enter the name : Jane

Enter the basic pay : 20000

Sample Output :Employee Id: E101
Employee Name: Jane
Net Salary : 22600.00 

Code :-

class Employee:
    def __init__(self,employee_id,employee_name,basic_pay):
    def calculate_net_salary(self):
        return net_pay
eid=input("Enter the employee id:")
ename=input("Enter the employee name:")
basic_pay=float(input("Enter the basic pay:"))


print("\nEmployee Id:",emp_obj.employee_id)
print("Employee Name:",emp_obj.employee_name)

print("Net Salary :%.2f" %net_salary)

Leave a Comment

Your email address will not be published. Required fields are marked *