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

Jill earns 1.5 times her normal hourly rate for each hour she works after 40 hours in a week. She worked 52 hours this week and earned $638. What is her normal
What is the formula of volume ofba rhombic prism
diary entry about my first day at school
how is nonverbal communication used in sports
1.Find the constant of variation for the relationship f(x)= 30x.  A.10  B.30  C.x  D.f(x)2.Find the constant of variation for the relationship shown in the foll
how is nonverbal communication used in sports
The school hall is 4 times as long as it is wide. If the perimeter is 55m, what is the length? and what is the width?
How does scarcity make countries interdependent?
why forces are balanced and unbalanced? need help with this the lesson is tommorow
one car travels east for 360 m over a period of 15 seconds. a second car travels west for 120 m over a period of 5 seconds. what is true about their speeds? the