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
Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
katovenus [111]

Answer:

He can use following computer program to make the class room more interesting and effective:-

  • 1. <u>Reference software</u> : This software help students to access the atlases and dictionaries.Teacher can include this software in research projects .

  • 2. <u>Educational Games</u>: This types of software is very effective for younger children because it motivates them to learn.This software companies have combined gaming and education into one .

  • 3. <u>Graphical software</u> : Student can use this software to create and changes images available on the internet itselfs .
4 0
3 years ago
Read 2 more answers
What is the purpose of a forecast worksheet?
Liono4ka [1.6K]

Answer: It’s a

Explanation:

I got it right on edj

8 0
2 years ago
This isn't a homework question but rather a technological problem. I connected my device to the motherboard but it will not dete
Helen [10]
Re start the computer again
5 0
3 years ago
Read 2 more answers
What is the half of 3/18
Zarrin [17]

Answer:

1/3

Explanation:

3/18 divided by 2 equals 1/3

hope this helps

have a good day

5 0
2 years ago
hich type of denial of service (DoS) attack occurs when a name server receives malicious or misleading data that incorrectly map
shusha [124]

Answer:

DNS poisoning

Explanation:

This type of attack is known as DNS poisoning it is a very common attack that focuses on trying to redirect users of the site that has been attacked towards fake servers. These fake servers belong to the attackers and are used to collect the user's private data, which can then be used by the attackers for a wide range of malicious acts. Aside from stealing user information, this malicious data travels alongside regular user data allowing it to infect various servers easily.

7 0
2 years ago
Other questions:
  • "a terminal has two input queues." as a user types each character to the terminal, it is collected in the ____ queue.
    5·1 answer
  • Knowledge can reside in email, voice mail, graphics, and unstructured documents as well as structured documents.
    9·2 answers
  • Give me give me keyboard on this phone please provide nice I can't type where is the keyboard.Give me give me keyboard on this p
    6·2 answers
  • After saving her presentation initially, Leah realizes she needs to add another content slide. She adds the slide and is ready t
    7·1 answer
  • A ____ client locates all or most of the processing logic on the server.
    11·1 answer
  • X = 0
    15·1 answer
  • To edit the color of the text in presentation software, choose the Font color command Text Color in the ________ ribbon toolbar.
    15·2 answers
  • Images from your .............. can be copied and pasted in a folder on your computer ​
    8·1 answer
  • Public class Main{ public static void main(String [] args){ String name=WelcomeJava; Runnable r1=() -&gt; System.out.println(nam
    12·1 answer
  • An operating system that allows a single user to work on two or more programs at the same time is what type of OS?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!