Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views2 pages

Notes 20250109170638

The document outlines a Payroll Management System that allows for the management of employee records, including adding, displaying, updating, and deleting employee information. It features functions for searching employees by name or post, and provides a simple text-based menu for user interaction. The system maintains an internal list of employee records with attributes such as serial number, name, post, age, and salary.

Uploaded by

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

Notes 20250109170638

The document outlines a Payroll Management System that allows for the management of employee records, including adding, displaying, updating, and deleting employee information. It features functions for searching employees by name or post, and provides a simple text-based menu for user interaction. The system maintains an internal list of employee records with attributes such as serial number, name, post, age, and salary.

Uploaded by

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

01.

09 5:05 PM
# Payroll Management System

# Initialize an empty list to store employee records


employees = []

# Function to add an employee


def add_employee():
print("Add Employee:")
serial_no = len(employees) + 1 # Automatically assign serial number
name = input("Enter Employee Name: ")
post = input("Enter Employee Post: ")
age = int(input("Enter Employee Age: "))
salary = float(input("Enter Employee Salary: "))
employees.append({'serial_no': serial_no, 'name': name, 'post': post, 'age':
age, 'salary': salary})
print("Employee added successfully!\n")

# Function to display all employees


def display_all():
print("Displaying All Employee Records:")
if not employees:
print("No records found!\n")
else:
for emp in employees:
print(f"Serial No: {emp['serial_no']}, Name: {emp['name']}, Post:
{emp['post']}, Age: {emp['age']}, Salary: {emp['salary']}")
print()

# Function to display employees by name


def display_by_name():
name = input("Enter the name to search: ")
found = False
for emp in employees:
if emp['name'].lower() == name.lower():
print(f"Serial No: {emp['serial_no']}, Name: {emp['name']}, Post:
{emp['post']}, Age: {emp['age']}, Salary: {emp['salary']}")
found = True
if not found:
print("No record found with the given name!\n")

# Function to display employees by post


def display_by_post():
post = input("Enter the post to search: ")
found = False
for emp in employees:
if emp['post'].lower() == post.lower():
print(f"Serial No: {emp['serial_no']}, Name: {emp['name']}, Post:
{emp['post']}, Age: {emp['age']}, Salary: {emp['salary']}")
found = True
if not found:
print("No record found with the given post!\n")

# Function to delete an employee record


def delete_record():
serial_no = int(input("Enter Serial No of the employee to delete: "))
for emp in employees:
if emp['serial_no'] == serial_no:
employees.remove(emp)
print("Employee record deleted successfully!\n")
return
print("No record found with the given Serial No!\n")

# Function to update an employee record


def update_record():
serial_no = int(input("Enter Serial No of the employee to update: "))
for emp in employees:
if emp['serial_no'] == serial_no:
print("Current Record:", emp)
emp['name'] = input("Enter New Name (Leave blank to keep current): ")
or emp['name']
emp['post'] = input("Enter New Post (Leave blank to keep current): ")
or emp['post']
emp['age'] = int(input("Enter New Age (Leave blank to keep current): ")
or emp['age'])
emp['salary'] = float(input("Enter New Salary (Leave blank to keep
current): ") or emp['salary'])
print("Employee record updated successfully!\n")
return
print("No record found with the given Serial No!\n")

# Main Program Menu


while True:
print("Payroll Management System")
print("1. Add Employee")
print("2. Display All Records")
print("3. Display by Name")
print("4. Display by Post")
print("5. Delete a Record")
print("6. Update a Record")
print("7. Exit")
choice = input("Enter your choice: ")

if choice == '1':
add_employee()
elif choice == '2':
display_all()
elif choice == '3':
display_by_name()
elif choice == '4':
display_by_post()
elif choice == '5':
delete_record()
elif choice == '6':
update_record()
elif choice == '7':
print("Exiting Payroll Management System. Goodbye!")
break
else:
print("Invalid choice! Please try again.\n")

You might also like