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
Ugo [173]
3 years ago
15

Write 3 functions in the starter code below such that: add_to_dict(): takes a dictionary, a key, a value and adds the key,value

pair to the dictionary. If key is already in dictionary then it displays the error message: "Error. Key already exists.". Returns dictionary. remove_from_dict(): takes a dictionary and key and removes the key from the dictionary. Returns dictionary. If no such key is found in the dictionary then it prints: "No such key exists in the dictionary.". Hint: Use try-except. find_key(dictt, key): takes dictionary and key and prints value corresponding to the key from the dictionary: print("Value: ", value). If key is not found, then prints: "Key not found." Hint: Use try-except
Computers and Technology
1 answer:
shepuryov [24]3 years ago
4 0

Answer:

Required code is given below:

Explanation:

def add_to_dict(dictt, key,value):

if key in dictt.keys():

print("Error. Key already exists.")

else:

dictt[key]=value

return dictt

def remove_from_dict(dictt,key):

try:

dictt[key]

dictt.pop(key, None)

return dictt

except KeyError:

print("No such key exists in the dictionary.")

def find_key(dictt,key):

try:

value=dictt[key]

print("Value: ", value)

except KeyError:

print("Key not found.")

You might be interested in
What is the definition of trouble shooting.
atroni [7]
<h2>Answer:</h2><h2>Trace and correct fault in mechanical or electrical system</h2>

5 0
3 years ago
A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
soldier1979 [14.2K]

Answer:

True

Explanation:

Computer is a device that is electronically designed to receive input, execute task on the input and give an output or resultant value. It's electronic hardware components are driven by a central software called the operating system. Input, output, memory and storage, and processor units are categories of the hardware components of the computer.

Peripheral hardware devices are externally attached to a computer system to maximise it's functionality. They are connected through extensions like ports, PCIe extensions etc.

5 0
3 years ago
Net Worth is equal to assets minus liabilities. Which event will have the greatest impact (positive or negative) on one's net wo
Orlov [11]
I would say that buying a house or apartment will in most people's cases have the greatest impact on the person's net worth. If it is bought in a big city like Vancouver it is highly likely that it will appreciate in value. At first it will be a iiability but after a few years if the marked is good  then the value will go up so the equity of the homeowner will increase thus increasing net worth.
8 0
3 years ago
(Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
Troyanec [42]

Answer:

If this is for fun. then may I take points for free. If not, then I will post my answer :)

Explanation:

5 0
3 years ago
A radio and communications security repairer is responsible for both radio and satellite communication systems.
natita [175]
I'm almost certain the answer is true
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following characters at the beginning of a cell signifies to Excel that it should perform a calculation for the val
    13·1 answer
  • Discus the pros and cons of Internal cloud service and External cloud service for both Infrastructure as a service and Applicati
    11·1 answer
  • Write a function to add two large integers of any length, say up to 200 digits. A suggested approach is as follows: treat each n
    12·1 answer
  • As a consommé simmers, the meat and eggs coagulate, forming a
    6·1 answer
  • Which type of fiber-optic connector, containing one fiber-optic strand per connector, is connected by pushing the connector into
    7·1 answer
  • What does the FixedUpdate loop do? Why do developers use it?
    14·1 answer
  • You work for a company that builds custom PCs for select clients. You are training a new employee to evaluate and select appropr
    13·1 answer
  • Netflix shows to watch?
    11·2 answers
  • Can maybe someone play with me on Over-watch on the Xbox?
    8·1 answer
  • Describe the main roles of the communication layer, the network-wide state-management layer, and the network-control application
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!