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
You can use ___________ to add dynamic features to a webpage such as search box that completes your search text automatically.
jonny [76]

Answer:

JavaScript

Explanation:

JavaScript is one of the simplest programming languages which makes the page dynamic and user interactive. It is a command based programming language that is a part of DHTML (Dynamic hypertext markup language ). The dynamic web page can be modified and its values can be changed.

JavaScript allows users to enter the value and provide the result at the same time and very fast.

JavaScript can be used online or offline too.

JavaScript provided much functionality such as when a customer searches anything, it completes the search automatically.

5 0
3 years ago
Original Problem statement from the Text: A retail company must file a monthly sales tax report listing the sales for the month
uysha [10]

Answer:

a

Explanation:

8 0
3 years ago
A certain database has numerous tables, but they do not share any fields in common. this database will not be as powerful as oth
IRINA_888 [86]
<span>A certain database has numerous tables, but they do not share any fields in common. this database will not be as powerful as others because it is not relational.  In </span><span>a relational database the data elements are dividing the data elements into related tables. Once ready to start working with the data, one can rely on relationships between the tables to pull the data together in meaningful ways.</span>
4 0
3 years ago
Read 2 more answers
The front page of Reddit is "democratic" because:
Rina8888 [55]
The people of Reddit vote for what they want seen and heard, the people of Reddit vote for something that represents them using upvotes.
3 0
4 years ago
Read 2 more answers
Please help me answer this<br><br>number 1..
beks73 [17]

Answer:

B. How well it conveys information

Explanation:

The most important thing is how we represent the data in a graphic to understand the purpose, we can make an example, but we're going to use the color, can be more effective in a weather chart, for temperatures or clouds, but in an organization, we can use color on red or green numbers, in this way to convey bad and good numbers.

4 0
3 years ago
Other questions:
  • An auxiliary view is always projected from the view that shows the inclined surface as a(n) _____.
    14·1 answer
  • For window 7 explain the steps you will use to find the available program you will list.
    13·1 answer
  • Write a function that creates a one-dimensional game board composed of agents of two different types (0 and 1, X and O, stars an
    11·1 answer
  • _______ is a form of crime that targets a computer system to acquire information stored on that computer system, to control the
    12·1 answer
  • Does this mean that the radius is the input aka 3 ? what about the PI ?
    14·1 answer
  • 2.3 Code Practice: Question 2
    5·1 answer
  • Why do the Brainly ads not end even after the timer reaches 0? Sometimes the Done Button does not appear.
    5·2 answers
  • Both Wireshark and NetWitness Investigator can be used for packet captures and analysis. Which tool is preferred for each task,
    13·1 answer
  • We cannot imagine a life without the Internet. Imagine that you had to live without being connected to the Internet. Discuss the
    13·1 answer
  • Describe two steps to find if photos can be legally used
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!