Python Practice › Set Programs › Program 16

Sum of a set

EasySet Programs · 16 of 48

Write a Python program to add up the elements of a set.

Advertisement
Input
{10, 20, 30}
Output
60

Approach

  1. sum().

Solution

Python
print(sum({10, 20, 30}))
Output
60

Learn the concept

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

More set programs

← All 48 Set Programs

Leave a Comment