lilgov602 lilgov602
  • 22-10-2020
  • Computers and Technology
contestada

Complete the following code snippet so that all of the negative values my_dict will be changed to zero. for key, value in _______: if value my_dict[key]

Respuesta :

IfeanyiEze8899 IfeanyiEze8899
  • 27-10-2020

Answer:

for key, value in my_dict.items():

   my_dict[ key ] = 0 if value < 0

Explanation:

Dictionary in python is an unordered and unindexed data structure, which is arranged in key-value pairs. To loop through the dictionary, the items() method is used on the dictionary finding the key and value on each iteration.

A value can be retrieved and changed using bracket notation and the key name of the value in question.

Answer Link

Otras preguntas

Identify the given item as probability distribution, continuous random variable, or discrete random variable. The heights of buildings in a metropolitan area.
Running a mile involves
What is the oxidation number of Chlorine in NaClO4? -1 +7 -5 +1
How can you tell something is a nuclear reaction rather than just a chemical reaction? pls help! A- energy has been lost as a result of the interaction B- energ
z-score of 0.02 what can you assume about the value in relation to the mean
Running a mile involves
Discuss how morphologic changes to modern humans' faces, mandibles, and teeth changed after the shift to agriculture and consumption of softer foods.
Vaccinations are able to provide protection against certain microorganisms because
Which of the following incidents has been added to the play Joe Magarac and the Hunkietown Contest so that it is different from the short story “Joe Magarac, Ma
How did progressivism influence wilson’s speech?