Professional Documents
Culture Documents
Program of Tuple
Program of Tuple
Program 2
#program to find maximum and Minimum, sum and mean value of tuple
T=tuple()
n=int(input('Enter number of elements '))
for i in range(n):
num=int(input('Enter any number '))
T=T+(num,)
print("Tuple created is ",T)
#output is
Enter number of elements 3
Enter any number 10
Enter any number 35
Enter any number 25
Tuple created is (10, 35, 25)
Maximum value is 35
Minimum value is 10
sum of Value of Tuple is 70
Mean of Value of Tuple is 23.32
Program 3
#program to count frequency of element in tuple
T=tuple()
n=int(input('Enter number of elements '))
for i in range(n):
num=int(input('Enter any number '))
T=T+(num,)
print("Tuple created is ",T)
for item in T:
print(item,'appear in tuple',T.count(item), ‘times’ )
Program 4
#program to search an element in tuple
T=(10,20,30,40,50,60,70,80,90,100)
s=int(input("Enter element to search "))
found=0
for item in T:
if item==s:
print("Element is found at index ",T.index(item))
found=1
if found==0:
print("Element not Found ")