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]
2 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]2 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
A set of communication rules for the computer to follow is called, what?
Irina-Kira [14]

The answer to this question is protocol

5 0
2 years ago
Read 2 more answers
Can someone let me join your kingdom if anybody knows this game and plays it as well. ​
Assoli18 [71]

Answer:

sure is called voxetas

Explanation:

7 0
3 years ago
After the following code is executed what will be displayed on the screen? bool correntEmployee = true; double empSalary = 45000
AlexFokin [52]

Answer:

"The employee pay rate is normal" is the correct answer for the above question.

Explanation:

  • The above question code is written in the c++ language, in which there is one variable of bool type whose value is true.
  • And this variable is also tested in the if-condition which gives the true and the if-body will be executed.
  • Then the internal if-condition will give the false result because the value of the empsalary is not less than 45000. It is because the above statement "empsalary=45000" will assign the value 45000 on the empsalary variable.
  • Then the else block will be executed which prints "the employee pay rate is normal".

7 0
3 years ago
Breaking down a problem to find the solution is called:
velikii [3]
I would say B.......
7 0
3 years ago
_ ports are audiovisual ports typically used to connect large monitors. These ports are used with many Apple Macintosh computers
cestrela7 [59]

Thunderbolt ports are audiovisual ports typically used to connect large monitors.

<h3>What is a Thunderbolt port?</h3>

A Thunderbolt is known to be used in systems by users. It is one that helps its users to be able to use one cable to have an access to a high-speed and high-resolution media.

This is often done by using one port along with a cable that is able to access both DisplayPort and PCI Express. Thunderbolt is known to contain technology that has been built into it that helps PCI Express speed to come in a good and better way.

Learn more about ports  from

brainly.com/question/10097616

4 0
2 years ago
Other questions:
  • Look at the slide. How could the slide best be improved? By reducing the number of visual aids by increasing the font size by da
    8·2 answers
  • What internet service provider first dominated the internet in the 1990s?
    15·1 answer
  • What is data security
    14·1 answer
  • Choose the false statement below. The content that displays in the browser is contained in the head section. The content that di
    14·1 answer
  • Write a program "addnumbers.c" where it takes as many arguments as the user includes as command line arguments and calculates th
    11·1 answer
  • Which is the last step in conducting a URL search?
    14·2 answers
  • What is the difference between edge and core networks?
    13·1 answer
  • MULTIPLE CHOICE QUESTION PLEASE HELP!!!!!!!!!
    14·2 answers
  • A computer is performing a binary search on the sorted list of 7 numbers below. What is the maximum number of iterations needed
    15·1 answer
  • If you walked into a room containing three computers and were told one of them was infected with malware, how would you determin
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!