Monday, December 9, 2019

write a program to take a tuple of numbers from the keyboard and print sum ,avg

a=eval(input("Enter  some of tuple numbers"))
l=len(a)
sum=0
for x in a:
    sum=sum+x
print("The sum=",sum)
print("The avg=",sum/l)

output:
Enter  some of tuple numbers(10,20,30)
The sum= 60
The avg= 20.0

No comments:

Post a Comment

python class topic video