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
Can you please help me?
DochEvi [55]

Answer:

  1. Pre-edited footage, usually direct from the camera.
  2. Process or result of selectively sequencing video and/or audio clips into a new video file.
4 0
3 years ago
Who is involved in helping shape the emotional impact of a film? (Select all that apply.)
Allisa [31]

All of the above

Explanation:

8 0
4 years ago
Read 2 more answers
Research different ways that 3D printing is used in society. Tell us about the items that are 3D printed.
Brrunno [24]
3D printing helps to reduce the time it takes for a manufacturer to create the product. This lets manufacturers invest their time to make flawless products because the production cycle time is reduced.
8 0
3 years ago
Read 2 more answers
You are creating a web page as part of a science project. Your role is to put your data on the webpage. You tracked the growth o
zysi [14]

The best way to represent this information on a web page is to put it on a table. I would use the <table> tag to create the table element. The <tr> tag for creating a series of row elements, the <td> tag to create cell divisions and the <br> tag for a line break.

I would use 10 rows for different plants and 8 columns for different points in time.

<em>Hope this helps :)</em>

7 0
2 years ago
Read 2 more answers
Calculating mean for even number and use while loop<br>pleas help me ​
vladimir2022 [97]

Answer:

Here is my answer in Javascript

num = 0;   // Use to calcate the even numbers

loop = 10; // Use for the highest even number that will be calcated for

index = loop/2; // Calcate the size of the array based upon how many loops their

let arr = [index]; //Create array to store the even numbers

let i = 0; // Use to keep track of which on what number in the while loop we are on  

let total = 0; //Used to add up all of the even numbers

let mean = 0; //Used to calcate the mean of all even numbers

do {

 i = i + 1; //Keep track of what loop we are on

 num = num + 2; //Used to calcate the even number

 arr.push(num); //Push the num into a array

 total = total + arr[i]; //Calcate the total of the array

 mean = total / i; //Calcate the mean

}

while (num != loop);

//Output the result

console.log(mean);

8 0
3 years ago
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • When does a kernel panic occur?
    12·2 answers
  • Social scientists who study criminal behavior.
    7·2 answers
  • Largest operating expenses include
    7·1 answer
  • Pls give me some suggestion of good Computer Science reference books for XI CBSE. <br> PLS!!
    10·2 answers
  • Which term describes the distance from one point on a wave to the same point on the next wave?
    13·2 answers
  • *
    6·2 answers
  • How do you distinguish between misrepresentation and embellishment of one’s professional accomplishments on a résumé? Provide an
    14·1 answer
  • HELP ASAP!!<br> What is the difference between an internal event and an external event?
    10·1 answer
  • How does the dns help the world wide web scale so that billions of users can access billions of web pages?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!