Home ยป Find Sum of Tuple Items using Python

Find Sum of Tuple Items using Python

Spring Framework Basics Video Course
1 Year Subscription
Java SE 11 Programmer II [1Z0-816] Practice Tests
Java SE 11 Programmer I [1Z0-815] Practice Tests
Oracle Java Certification
Java SE 11 Developer (Upgrade) [1Z0-817]

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

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More