You are on page 1of 2

Program 1

#program to create a 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)

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)

print('Maximum value is ',max(T))


print('Minimum value is ',min(T))
print('sum of Value of Tuple is ',sum(T))
mean=sum(T)/len(T)
print('Mean of Value of Tuple is ',mean)

#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 ")

You might also like