Python Program to Find the Sum of All the Items in a Dictionary

This is a Python Program to find the sum all the items in a dictionary.

Problem Description

The program takes a dictionary and prints the sum of all the items in the dictionary.

Problem Solution

1. Declare and initialize a dictionary to have some key-value pairs.
2. Find the sum of all the values in the dictionary.
3. Print the total sum.
4. Exit.

Program/Source Code

Here is source code of the Python Program to find the sum all the items in a dictionary. The program output is also shown below.

d={'A':100,'B':540,'C':239}
print("Total sum of values in the dictionary:")
print(sum(d.values()))
Program Explanation

1. The sum() function is used to find the sum of all the values in the dictionary.
2. The total sum of all the values in the dictionary is printed.
3. Exit.

advertisement
Runtime Test Cases
 
Case 1:
Total sum of values in the dictionary:
879

Sanfoundry Global Education & Learning Series – 1000 Python Programs.

If you wish to look at all Python Programming examples, go to 1000 Python Programs.

🔥 Enroll for Free Data Structure Certification - January 2026

👉 For weekly programming practice and certification updates, join Sanfoundry’s official WhatsApp & Telegram channels

advertisement
Manish Bhojasia – Founder & CTO at Sanfoundry

I’m Manish, Founder & CTO at Sanfoundry, with 25+ years of experience across Linux systems, SAN technologies, advanced C programming, and building large-scale, performance-driven learning and certification platforms focused on clear skill validation.

LinkedIn  ·  YouTube MasterClass  ·  Telegram Classes  ·  Career Guidance & Conversations