max python

Just another WordPress site

Find Sum of Tuple Items using Python

In this example we use the sum function to return the sum of all tuple items.

Example

# Sum of All Items

number_tuple = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print("Tuple Items = ", number_tuple)

tuple_sum = sum(number_tuple)
print("\nThe Sum of Tuple Items = ", tuple_sum)

When you run this you will see something like this

>>> %Run sumtuple.py
Tuple Items =  (10, 20, 30, 40, 50, 60, 70, 80, 90)

The Sum of Tuple Items =  450

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :