Mean of dictionary values

EasyDictionary Programs · 38 of 94

Write a Python program to find the mean of a dictionary’s values.

Advertisement
Input
{"m1": 25, "m2": 20, "m3": 15}
Output
Mean is 20.0

Approach

  1. sum / len.

Solution

Python
d = {"m1": 25, "m2": 20, "m3": 15}print("Mean is", sum(d.values()) / len(d))
Output
Mean is 20.0
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More dictionary programs

← All 94 Dictionary Programs