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

The name of each contestant is written on a separate card, the cards are placed in a bag, and three names are picked from the bag. Identify which type of sampli
the one to one functions G and H are defined as followG={(-8,1),(1,5),(4,-5)(8,-9)}H(x)=3x+4find the following g^-1(1)=h^-1(x)=(h^-1oh)(-2)=
How many faces edges vertices does a decagonal prism have ?
A second baseman tosses the ball to a first baseman, who catches it a the same level from which it was thrown. The throw is made with an initial speed o 19.0 m/
Insert 2 irrational numbers between 2/5 and 3/4
How many faces edges vertices does a decagonal prism have ?
What is the passive voice of "I went to a movie"
How do I solve for x and state the restriction if (a-c)/(x-a)=m
what is a dangling modifier?
the one to one functions G and H are defined as followG={(-8,1),(1,5),(4,-5)(8,-9)}H(x)=3x+4find the following g^-1(1)=h^-1(x)=(h^-1oh)(-2)=