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

7th grade help me plzzzz
What is the mass of 50mL of water when you dont know the density
Write an equation of the line with a slope of -3/4 and y-intercept of -6.​
Why is 6 afraid of 7?
What is the last sequence for Silver 4d7 4d7 4d9 4d9 4p2 4p2 3d7
I’m freaking out I can’t find this I’m going to cry.
what factors drove imperialism
Underground there are plates within the Earth. These plates are responsible for Earthquakes. When certain plates move, it creates a seismic wave that carries en
"'Russian intentions regarding U.S. Election infrastructure remain unclear.' Moscow's intelligence agencies . . . May have 'intended to exploit vulnerabilities
Consider the function f(x) = 13x^2 + 13x + 15 Evaluate f(-3)