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

What is one third of 1080
If two parents that are heterozygous (Aa) at a single locus give rise to offspring that are 25 percent AA, 50 percent Aa, and 25 percent aa, then all of the fol
The freezing and thawing action of water affects a rock by?
A study was designed to determine how test scores on a 20-question test were related to the time spent studying for the test. What are the independent and depen
Are the graphs of y=3/8x -5 and y=3/8x +2 parallel?
If two parents that are heterozygous (Aa) at a single locus give rise to offspring that are 25 percent AA, 50 percent Aa, and 25 percent aa, then all of the fol
how do u do these equations?
John and Bill walk towards to each other’s house. If both leave at 10 am, they meet 10 minutes later. If Bill leave 3 minutes later then John, they’ll meet 9 mi
What is the dating process that doesn't exactly identifies the age of a rock?
what did republicans think about slavery in territories