Python Practice › Set Programs › Program 17

Average of a set

EasySet Programs · 17 of 48

Write a Python program to find the average of the elements of a set.

Advertisement
Input
{4, 8, 15, 16, 23, 42}
Output
18.0

Approach

  1. sum / len.

Solution

Python
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.

More set programs

← All 48 Set Programs

Leave a Comment