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
How many nibbles make one kilobyte​
Kazeer [188]
2000 nibbles I think correct me if I’m wrong
5 0
3 years ago
Read 2 more answers
Every preprocessing directive must begin with:
Anni [7]

Answer:

B. #

Explanation:

Every preprocessing directive must begin with the # character.

For example:

#define : Used to define a macro

#ifndef : Conditional evaluation of macro

#include : Used to include other preprocessor header file as part of the code

As we can see each of the directives begins with the # character. This is a signal to the preprocessor to interpret the subsequent keyword as a directive.

3 0
3 years ago
I damaged a k12 laptop. do I have to pay for the damage? and if so how much?
Gnesinka [82]

You explain your situation, they send you a new computer, then mail to them the broken computer and later pay a $200-350 dollar fee. I think it depends on how much damage you made to it.

5 0
3 years ago
How much is a stock supra 1998​
saveliy_v [14]

Answer:

Hatchback Original MSRP / Price Engine

Supra 3dr LB Auto $31,078 / $29,122 6 Cylinder

Supra 3dr LB Sport Roof Auto $35,648 / $32,842 6 Cylinder

Supra 3dr LB Sport Roof Turbo Auto $38,778 / $35,903 6 Cylinder Turbo

Supra 3dr LB Sport Roof Turbo Manual $40,508 / $37,362 6 Cylinder Turbo

Explanation:

5 0
3 years ago
How do I delete my account on Brainly? It says I must enter my password to do so, but I never set up a password. When I try the
Lady_Fox [76]
Try using your email account password
8 0
3 years ago
Other questions:
  • Show the contents of a queue after the following operations are performed. Assume the queue is initially empty. enqueue(45); enq
    6·1 answer
  • Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
    5·1 answer
  • Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb
    12·1 answer
  • ANYONE GOOD WITH CODING IN C++
    14·1 answer
  • Divide 111001 by 1101​
    7·1 answer
  • Explain software piracy and Hacking​
    13·2 answers
  • Please answer this simple (hard) question for me lol
    13·2 answers
  • Which of the following correctly orders the units of measure from least to greatest?
    7·2 answers
  • what is cicada 3301? i will give brainliest if you give me a correct answer (not copy and pasted) and somewhat well detailed, i
    8·1 answer
  • The most serious security threat to Bluetooth-enabled devices is ____, which occurs when a hacker gains access to the device and
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!