Python Practice › Set Programs › Program 17
Average of a set
Write a Python program to find the average of the elements of a set.
Input
{4, 8, 15, 16, 23, 42}Output
18.0
Approach
sum / len.
Solution
s = {4, 8, 15, 16, 23, 42}print(sum(s) / len(s))Output
18.0
Learn the concept
New to this topic? Read the lesson, then come back.