Robotics & Artificial Intelligence
Write a Python program to add all the elements of a tuple.
Python Control Flow
1 Like
Answer
t = (10, 20, 30, 40)
s = 0
for i in t:
s = s + i
print("Sum of elements of the tuple is:", s)Output
Sum of elements of the tuple is: 100
Answered By
3 Likes
Related Questions
Write a program to find the smallest number among three numbers by using the nested 'if-else' statements.
Write a Python program to check that if a given number is even or odd.
Write a program to delete/remove all the numbers less than 10 from the list.
Write a Python program to find the largest element in a tuple.