+ 2

What is the output of this code ?

dict={1:15,5:10,4:26} sum=0 for value in dict : sum=sum+value print(sum)

26th Jun 2019, 4:05 PM
Indira
Indira - avatar
2 Answers
+ 6
It's output is 10. Because during the execution of "for loop" every time key will be extracted from dict and get added to sum. sum=0+1 = 1 sum=1+5 = 6 sum=6+4 = 10
26th Jun 2019, 4:59 PM
Manisha Sahu
Manisha Sahu - avatar
+ 1
10, because it adds the keys, not the values: 0 + 1 + 5 + 4 = 10
26th Jun 2019, 4:20 PM
Airree
Airree - avatar