Question: 7. Given a dictionary in Python , write a Pythonprogram to find the sum of all Items in the dictionary. Method 1: Use the built-in
7. Given a dictionary in Python, write a Pythonprogram to find the sum of all Items in the dictionary.
Method 1: Use the built-in sum() function to find the sum ofdictionary values. Hint: create a list and add the valuesto the list.
Method 2: Iterate through each item of the dictionary and simplykeep adding the values to the total variable.
Sample result:
Input : {'x': 25, 'y':18, 'z':45}
Output : 88
PLZ SHOW THE CODE!!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
