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
Gettier contributed to what we know about the __________ model, while Rosch contributed to what we know about the __________ mod
svet-max [94.6K]

Gettier contributed to what we know about the exemplar model, while Rosch contributed to what we know about the prototype model. Prototype and exemplar theories are both versions of statistical theories of concepts. Prototype theories hold that concepts represent categories by means of a summary of the typical properties that category members possess, while exemplar theories hold that concepts represent categories by means of a cluster of individual category members that may be used to extract the statistical central tendency of the category.

6 0
3 years ago
Read 2 more answers
Which of the following STEM discoverers is known as the “Prince of Math?”
Margarita [4]
The German mathematician & physicist ”Carl Friedrich Gauss”

Born: April 30, 1777, Brunswick, Germany
Died: February 23, 1855, Göttingen, Germany
8 0
3 years ago
In your own words, describe the advantages and disadvantages of the auto-negotiation protocol used in Ethernet communications.
dexar [7]

Answer:

 Auto-negotiation protocol is the modern technology in the networking. This protocol allow the ethernet equipment for automate different instillation steps. This type of protocol use by interconnecting various electronic devices for negotiating the speed of the link.  

Advantages:

  •  The auto negotiation protocol features used to maximize the throughput of data link layer.
  •  This protocol are basically useful in the local area network (LAN), with multiple capability of connections.
  •  The auto negotiation protocol extremely useful in twisted pair which are based on ethernet.

Disadvantages:

  •   This type of protocol are not fixed data links and not used as backbone of the networks.  
  •  Duplex mismatch occur then, it cause significant loss in the packets.

7 0
3 years ago
We use _____command to get data from the user? (python)
Genrish500 [490]

Answer:

INPUT

Explanation:

EXAMPLE PYTHON CODE

_______________________________________________________

INPUT CODE:

_______________________________________________________

foo = input('foo: ')#Have some text printed before the input field

bar = foo

print(bar)

_______________________________________________________

OUTPUT CODE:

_______________________________________________________

foo: Hello World!

Hello World!

>>> bar

'Hello World!'

>>>foo

'Hello World!'

5 0
3 years ago
What could cause this? An App Builder wants to show Groups as the last navigation menu item in the Salesforce1 Mobile App. Howev
sasho [114]

Answer:

Option B is the correct option.

Explanation:

In the above scenario, When they wanted to demonstrate Groups as the last menu item for navigation in the Mobile App. Then, they can't select Groups as among the elements in the drop-down menu though.

So, the following scenario causes that the Groups are not contained in the selected list for the navigation menu.

4 0
3 years ago
Other questions:
  • What is the output after the following code executes?
    14·1 answer
  • With a patent on drug Z27, why would Able Drug Company charge customers $7 per 100 units even though its cost of producing 100 u
    5·2 answers
  • An ethernet switch has a ____ table which is updated by ______.
    14·1 answer
  • In addition to the decimal number system, the number systems used most often in PLC operationand programming are ________.
    9·1 answer
  • Placeholders can hold text but not graphics such as photos or charts. True or false?
    7·1 answer
  • What is the difference between a switch and a hub?
    8·1 answer
  • The scientific process is most similar to what
    10·1 answer
  • Simplify 0.2×0.03055 to 3 decimal places​
    15·2 answers
  • What is the difference between websites and web page​
    8·1 answer
  • What is the difference between a LAN and WAN? how do these two networks interact?​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!