1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tasya [4]
2 years ago
9

Write a program that unpickle's employee dictionary and while reading from the dictionary, it allows users to lookup an employee

in the dictionary, add/update/delete an employee, or quit the program. You must have the following in place: Your program must be in the root directory that you store "Employee.py" file; this way you can import the Employee as a module (hint: import Employee). You must also import "pickle" and "random" modules. For using the methods in Employee object you should call it by Employee.Method_Name()
Computers and Technology
1 answer:
melamori03 [73]2 years ago
7 0

Answer:

Check the explanation

Explanation:

from Employee import *

import pickle

import random

def unpickle_employee(filename):

file=open(filename,'rb')

data=pickle.load(file)

file.close()

return data

def pickle_employee(data,filename):

file=open(filename,'wb')

pickle.dump(data,file)

file.close()

if __name__=='__main__':

filename="Employees.dat"

'''

E=Employee("Ajay",1,"R&D","Manager")

data={}

data[1]=E

pickle_employee(data,filename)

'''

data=unpickle_employee(filename)

 

while True:

print("\nData In Employee.dat")

for d in data:

print("Employe data: ",data[d].get_name(),"({},{},{})".

format(data[d].get_id_number(),data[d].get_department(),data[d].get_job_title()))

 

print("\n\n\t\tMenu")

print("To add new Employee, Enter a")

print("To update any Employee, Enter u")

print("To delete any Employee, Enter d")

print("Enter anything to quit")

choice=input("Enter: ")

if choice=='a':

id_number=random.randrange(100,200,1)

while id_number in data:

id_number+=1

if id_number>=200:

id_number=100

name=input("Enter the Name: ")

department=input("Enter the Department: ")

job_title=input("Enter the job title: ")

E=Employee(name,id_number,department,job_title)

data[id_number]=E

elif choice=='u':

id_number=int(input("Enter the Employee id_number to update: "))

for d in data:

print(id_number,d,d==id_number)

if id_number in data:

print("Employe data: ",data[id_number].get_name(),"({},{})".

format(data[id_number].get_department(),data[id_number].get_job_title()))

print("\nPlease Enter the details")

name=input("Enter the Name: ")

department=input("Enter the Department: ")

job_title=input("Enter the job title: ")

E=Employee(name,id_number,department,job_title)

data[id_number]=E    

else:

print("Employee doesn't exist\n")

elif choice=='d':

id_number=int(input("Enter the Employee id_number to delete: "))

if id_number in data:

print("Employe data: ",data[id_number].get_name(),"({},{})".

format(data[id_number].get_department(),data[id_number].get_job_title()))

choice=input("\nPlease Enter y to confirm, anything else to cancel: ")

if choice=='y':

del data[id_number]

else:

print("Employee doesn't exist\n")

else:

break

pickle_employee(data,filename)

You might be interested in
2. Kabel yang digunakan pada jangan wireline, sebagai
Mumz [18]
It’s b ........................................
7 0
2 years ago
Discuss, in detail, the usefulness of graphics and images in program development. Explain the importance of the interface of a c
vesna_86 [32]

Answer:

Explanation:

The main importance of graphics and images in program development is user experience. These graphics, color schemes, clarity, images etc. all come together to create a user interface that individuals will be able to easily navigate and use with extreme ease in order to benefit from what the program is intended to do. An interface of a class of objects allows every button and object in the program to grab and share functionality in order for the entire program to run smoothly.

4 0
2 years ago
Each peripheral device has its own software, called a(n) ____, which contains the detailed instructions required to start that d
olga nikolaevna [1]
OS or operating system
4 0
3 years ago
What is the utility of a lever?
Kamila [148]
Muy cosas.
 fazer una montanha russa andar,ativar una armadilha, ativar una puerta etc.
3 0
3 years ago
Read 2 more answers
What is a unit to measure loudness
FinnZ [79.3K]

decibels i believe is the correct answer. hope it helps :)

3 0
2 years ago
Other questions:
  • You are troubleshooting an interface issue on your cisco ios isr. the output of "show ip interface brief" indicates that etherne
    11·1 answer
  • If you wanted to make certain numbers in a spreadsheet stand out, you should _____.
    11·2 answers
  • Which of the following statements is true of ASCII code?
    12·1 answer
  • What is the importance of Mathematical Modeling in the field of bioinformatics.
    8·1 answer
  • When the CSS property of position is set to ____ it moves the element relative to its original position and allows other element
    10·1 answer
  • Which type of server runs Active Directory?
    12·1 answer
  • What are attribute grammars used for?
    8·1 answer
  • What are Important points to include about preventing the download of malware?
    14·1 answer
  • Citing Wikipedia as a reference is not considered a good practice because 1.leverages a neutral point of view. 2.hosts unopinion
    8·1 answer
  • Explain the difference between undecidable problems and unreasonable time algorithms. Be specific.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!