Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Employee:
- """Creates a Employee Class"""
- def __init__(self):
- self.Details = dict()
- def add_details(self, empid, empname, empsal):
- self.Details[empid] = (empname, empsal)
- def show_details(self, empid):
- return self.Details.get(empid, "")
- def count(self):
- return len(self.Details)
- employee = Employee()
- print("There are No Details of any Employee!!!\nPlease Enter the Details of Employees First...")
- choice_get, choice_put = "y", "y"
- while choice_put.lower() == "y":
- empid = int(input("Enter the Employee ID : "))
- empname = input("Enter the Name of Employee : ")
- empsal = int(input("Enter the Salary of the Employee : "))
- employee.add_details(empid, empname, empsal)
- print("\nThe Record has been Added Successfully!!!")
- choice_put = input("\nDo You Want to Add More Details of Employees(Y/[N]) : ")
- print(f"\nYou've Added {employee.count()} Records Successfully!!!\nNow You may Retrieve any Record...")
- while choice_get.lower() == "y":
- empid = int(input("Enter the ID of the Employee's Record to be Retrieved : "))
- details = employee.show_details(empid)
- if any(details):
- print("\nThe Name of the Employee : ", details[0])
- print("The Salary of the Employee : ", details[1])
- else:
- raise KeyError(f"Oops!!! There is no Such Employee with ID as {empid}")
- choice_get = input("\nDo You Want to Retrieve More Details of Employees(Y/[N]) : ")
- else:
- print("Thank You!!!")
Advertisement
Add Comment
Please, Sign In to add comment