Question: Write a Python program that can be used to store records of employees. The employee details are stored in a dictionary, with the employee code
Write a Python program that can be used to store records of employees. The employee details are stored in a dictionary, with the employee code as the key, and a nested dictionary that stores the name, surname, email address, and department as value. The employee code comprises of the first letters of the department name, followed by a hyphen, and a randomly generated number between and The dictionary must be managed using a class. The program should have the following:
Employee record class: a class used to initialise and maintain the dictionary. The class must have the following methods:
oGenerate employee code: takes in the department and generates an employee code as specified above. Ensure that the employee code generated does not exist in the dictionary, to ensure unique keys.
Marks
oAdd employee record: takes in the name, surname, email, and department of the employee, then adds it to the dictionary. The employee code used as the key must be generated using the Generate employee code method.
Marks
oPrint employee codes: A method that prints all the employee codes generated.
Marks
oPrint employee dictionary: A method that prints all the employee records in the dictionary.
Mark
oSearch employee: Takes in the employee code and prints the details associated.
Marks
Main menu: A menu used to navigate through the program. The menu must be displayed until the program terminates.
Marks
Sample outputs: Add employee record
Display all employee codes
Display all employee records
Search employee
Exit
Select a menu option:
Enter name:Marcel
Enter surname: Kish
Enter department: Sales
Enter email: mk@mkmk
Add employee record
Display all employee codes
Display all employee records
Search employee
Exit
Select a menu option:
IT
SA
Select a menu option:
IT: name: 'Marc', 'surname': 'Kish', 'department': IT 'email':
mk@mkmkSA: name: 'Marcel', 'surname': 'Kish', 'department': 'Sales',
'email': mk@mkmk
Select a menu option:
Enter employee code: IT
name: 'Marc', 'surname': 'Kish', 'department': IT 'email': mk@mkmk
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
