Employee Management System - Python Task 07 (OOP)
The purpose of this task is to understand and implement Object-Oriented Programming (OOP) concepts in Python by building a menu-driven Employee Management System using Classes and Objects. This system demonstrates real-world application of OOP principles used in enterprise applications.
- Employee Class - Defined with attributes: Employee ID, Name, Department, Designation, Salary
- Add Employee - Insert new employee records with validation
- View All Employees - Display all records in clean tabular format
- Search Employee - Search by Employee ID or Name
- Update Employee - Modify Department, Designation, or Salary
- Delete Employee - Remove employee records by ID
- Salary Statistics - Calculate and display:
- Highest Salary
- Lowest Salary
- Average Salary
- Total Employees
- Export Data - Save employee records to:
employees.csv(Comma-Separated Values)employees.txt(Text Format)
- Read CSV/TXT - Read and display file contents back
- ✅ Salary Increment Calculator - Calculate salary increments by percentage
- ✅ Department-wise Employee Count - Show count of employees per department
- ✅ Search by Department - Filter employees by department
- ✅ Sort by Salary - Display employees sorted by salary (highest to lowest)
- Language: Python 3.x
- Concepts:
- Classes and Objects
- Constructors (
__init__) - Methods and Instance Variables
- Encapsulation
- Lists of Objects
- File Handling (CSV, TXT)
- Exception Handling
- String Formatting
- System loads existing employee data from
employees.csv(if available) - Sample data is loaded on first run for demonstration
The program displays a menu with 14 options:
1. Add Employee
2. View All Employees
3. Search Employee
4. Update Employee
5. Delete Employee
6. Salary Statistics
7. Export Data (CSV)
8. Export Data (TXT)
9. Read CSV File
10. Salary Increment Calculator (Bonus)
11. Department-wise Employee Count (Bonus)
12. Search by Department (Bonus)
13. Sort Employees by Salary (Bonus)
14. Exit
- User inputs: ID, Name, Department, Designation, Salary
- System validates if Employee ID already exists
- Creates new Employee object
- Adds to employee list
- Saves to CSV automatically
- Displays success/error message
- Displays all employees in tabular format with columns:
- ID | Name | Department | Designation | Salary
- Shows formatted table with borders
- Handles empty list scenario
- User selects search type (ID or Name)
- System searches through employee list
- Displays results in table format if found
- Shows "Employee Not Found" if no match
- User enters Employee ID
- System displays current details
- User selects what to update (Department/Designation/Salary/All)
- Validates input and updates
- Saves changes to CSV
- Displays confirmation
- User enters Employee ID to delete
- System asks for confirmation
- Removes employee from list
- Saves updated list to CSV
- Shows success message
- Calculates and displays:
- Maximum salary across all employees
- Minimum salary across all employees
- Average salary
- Total number of employees
- Presented in formatted box
- CSV Export: Saves in standard CSV format with headers
- TXT Export: Saves in formatted text with timestamp and statistics
- Both include all employee records
- Automatic file creation/overwrite
- Reads and displays the contents of
employees.csv - Shows raw file format
- Salary Increment: Calculate new salaries with percentage increase
- Department Count: Summary of employees per department
- Search by Department: Filter employees by selected department
- Sort by Salary: Display employees ranked by salary (highest first)
-
Data Persistence:
- Challenge: Maintaining employee data between program sessions
- Solution: Implemented CSV file loading on startup and auto-saving after operations
-
Input Validation:
- Challenge: Handling invalid inputs (non-numeric IDs, duplicate IDs, invalid salaries)
- Solution: Used try-except blocks and validation checks for all user inputs
-
Tabular Display:
- Challenge: Formatting employee data in clean, readable columns
- Solution: Used Python string formatting with fixed column widths
-
Search Functionality:
- Challenge: Efficient searching through employee list
- Solution: Used list comprehension and lambda functions for flexible search
-
File Handling:
- Challenge: Reading and writing CSV files with proper formatting
- Solution: Used Python's csv module with proper encoding (UTF-8)
-
Update Flexibility:
- Challenge: Allowing selective updates of employee fields
- Solution: Implemented conditional update logic with user menu selection
- Classes and Objects - Created
EmployeeandEmployeeManagementSystemclasses - Constructors - Implemented
__init__for initializing attributes - Methods - Created multiple methods for different operations
- Encapsulation - Bundled data and operations within classes
- Lists of Objects - Managed collection of Employee objects
- File I/O - Read and write CSV/TXT files
- Exception Handling - Try-except blocks for error management
- Data Validation - Input checking and error messages
- String Formatting - Professional table formatting
- Algorithmic Thinking - Search, sort, and statistical calculations
- Code Organization - Well-structured, modular code design
- User Interface - Menu-driven system with clear prompts
- Foundational understanding of enterprise employee systems
- Database-like operations (CRUD - Create, Read, Update, Delete)
- CSV data handling (commonly used in data analysis)
- Scalable architecture for larger applications
- Python 3.6 or higher
- Text editor or IDE (VS Code recommended)
-
Save the file: Save
employee_management.pyin a folder (e.g.,Python_Task_07_YourName) -
Open Terminal/Command Prompt in the folder location
-
Run the program:
python employee_management.py
or
python3 employee_management.py
-
Follow the menu prompts to perform operations
-
Exit: Press option 14 to exit the program
Python_Task_07_YourName/
├── employee_management.py # Main program
├── employees.csv # Auto-generated data file
├── employees.txt # Auto-generated export file
├── README.md # This documentation
└── Screenshots/ # (Optional) Program screenshots
├── screenshot1.png
├── screenshot2.png
└── screenshot3.png
==================================================
🏢 EMPLOYEE MANAGEMENT SYSTEM
==================================================
1. Add Employee
2. View All Employees
3. Search Employee
...
14. Exit
==================================================
===========================================================================
ID Name Department Designation Salary
===========================================================================
101 Soham IT Developer 50000.00
102 Rahul HR Manager 65000.00
103 Priya Finance Analyst 55000.00
===========================================================================
==================================================
📊 SALARY STATISTICS
==================================================
Highest Salary: ₹75,000.00
Lowest Salary: ₹45,000.00
Average Salary: ₹58,000.00
Total Employees: 5
==================================================
✨ Professional Design
- User-friendly menu system
- Clear error messages
- Formatted output with proper alignment
- Unicode symbols for better UX (✅, ❌, 📊, etc.)
🔒 Data Validation
- Duplicate employee ID prevention
- Numeric input validation
- Salary format validation
- File existence checks
💾 Data Persistence
- Auto-save to CSV after each operation
- Load existing data on startup
- Multiple export formats (CSV, TXT)
⚡ Bonus Features
- Comprehensive salary increment calculations
- Department analytics
- Flexible search and sorting
- Professional report generation
Potential improvements for advanced implementation:
- Database integration (SQLite, MySQL)
- User authentication system
- Employee login functionality
- Advanced reporting and analytics
- Email notifications
- Web-based interface
- Performance optimization for large datasets
-
Create a folder:
Python_Task_07_YourName -
Include:
- ✅
employee_management.py(Main program) - ✅
employees.csvoremployees.txt(Sample data) - ✅
README.md(This documentation) - ✅ Screenshots (Optional but recommended)
- ✅
-
Upload to GitHub in your internship repository
-
Submit the GitHub link through the weekly submission form
- ✅ Classes and Objects
- ✅ Constructors (
__init__) - ✅ Methods and Instance Variables
- ✅ Object Creation
- ✅ Encapsulation
- ✅ Lists of Objects
- ✅ CSV File Handling
- ✅ Text File Handling
- ✅ Exception Handling
- ✅ Basic OOP Principles
Object-Oriented Programming is the backbone of modern software development. Frameworks like Django, Flask, FastAPI, and many enterprise applications are built using OOP concepts. Mastering these fundamentals will prepare you for building scalable and maintainable applications.
Created as part of White Band Associates - Python Internship Program Task: 07 - Object-Oriented Programming & Employee Management System
This project is part of an educational internship program. All rights reserved.