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]
3 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]3 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
You are trying to connect a new USB device to your computer. You install the driver and then connect the device to an open USB
nadezda [96]

Answer:

By order of increasing magnitude:

D. Make sure the USB device is plugged in properly.

A. Try a different USB cable.

B. Replace the USB device.

C. Install a new USB controller card.

Explanation:

Start with whatever is simplest first. Most errors are simply ID-10-T mistakes.

3 0
3 years ago
What is the best thing about Tuesday’s in general? Why?
Stolb23 [73]

Answer:

tbh I really don't know what you mean

4 0
4 years ago
A. Arrange the steps in opening a database. Number them from 1 to 4 using the blanks
Archy [21]

Answer:

__1_Click the Microsoft Office button and choose OPEN from the menu.

_2___It will list the files that can be opened using Microsoft Access.

__4__Select the document to open and click the OPEN button when done.

__3__The Open Dialog Box will probably open the folder MY DOCUMENTS.

6 0
3 years ago
RIGHT ANSWER I'LL GIVE U BRAINLIST which is not a component of the career poster project
blsea [12.9K]
B is the answer i believe
3 0
3 years ago
What is a system that uses computerized advisory programs to imitate the reasoning processes of experts in solving difficult pro
algol13

Answer:

Expert systems

Explanation:

Experts systems are known as computerized advisory programs that are used for the imitation of expert's reasoning processes when solving problems that pose a difficulty. They are usually a knowledge base that have several accumulated experience and certain rules that are used in the application of the knowledge according to the specific situation.

6 0
3 years ago
Other questions:
  • Ben has to write a note on color concepts. Help him complete the following sentences.
    10·2 answers
  • Write a program that opens a text le called quiz.txt for reading. This le contains a single line with a student's rst name then
    15·1 answer
  • Under normal operations, cisco recommends that you configure switch ports on which vlan
    5·1 answer
  • If you delete a file from removable media, it is stored in the recycle bin where you can recover it until you empty the recycle
    13·1 answer
  • Given two int variables distance and speed, write an expression that divides distance by speed using floating point arithmetic,
    11·1 answer
  • Jason Is Working On A Video Science Project. As He Is Working On It, He Saves The Project.
    5·1 answer
  • When does personal information often need to be entered online?
    15·1 answer
  • Which activity might require you to provide your social security number
    8·2 answers
  • Which two components help input data in a computer and select options from the screen, respectively?
    9·1 answer
  • What is the best way to beat someone on starve.io? with a lava sword, or a pirate sword.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!