0% found this document useful (0 votes)
6 views1 page

Employee Salary Slip Generator Code

The document contains a Python script that calculates and stores employee salary details using the pickle module. It prompts the user to input employee information, calculates various salary components, and saves the data to a file. Finally, it retrieves and prints a salary slip for each employee from the stored data.

Uploaded by

leondennis435
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Employee Salary Slip Generator Code

The document contains a Python script that calculates and stores employee salary details using the pickle module. It prompts the user to input employee information, calculates various salary components, and saves the data to a file. Finally, it retrieves and prints a salary slip for each employee from the stored data.

Uploaded by

leondennis435
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import pickle

def calculate(n):
f = open("[Link]", 'wb')
emp = {}
for i in range(n):
d = {}
print("Enter details of the employee", i + 1, ":")
empid = int(input("Enter employee id:"))
d['ename'] = input("Enter employee name:")
d['job'] = input("Enter Designation:")
d['bs'] = float(input("Enter basic salary:"))
d['hra'] = d['bs'] * 0.25
d['da'] = d['bs'] * 0.10
d['ta'] = d['bs'] * 0.05
d['gs'] = d['bs'] + d['hra'] + d['da'] + d['ta']
d['tax'] = d['gs'] * 0.12
d['ns'] = d['gs'] - d['tax']
emp[empid] = d
[Link](emp, f)
[Link]()
f = open("[Link]", 'rb')
try:
emp = [Link](f)
except EOFError:
pass
finally:
[Link]()

# Print the salary slip


print("\t\t\t----------- SALARY SLIP -----------")
print("ID\tNAME\tJOB\tB.S\tG.S\tTAX\tN.S")
for i in emp:
print(i, emp[i]['ename'], emp[i]['job'], emp[i]['bs'], emp[i]['gs'], emp[i]['tax'], emp[i]
['ns'], sep='\t')

# Input number of employees


no = int(input("Enter no. of employees: "))
calculate(no)

You might also like