Create a tuple and find the minimum and maximum number from it.
minmax.py
tup=(1,2,3,5,56,9,8,6,4)
largest=tup[0]
smallest=tup[0]
for i in tup:
if(i>largest):
largest=i
for i in tup:
if(i<smallest):
smallest=i
print("Largest number is :",largest)
print("Smallest number is :",smallest)
Output
Question 2
Write a Python program to find the repeated items of a tuple.
repeat.py
tup=(1,2,3,5,56,9,2,8,6,4,9,56)
list=[]
size=0
print("Repeated items are :",end=" ")
for i in tup:
size+=1
for i in range(0,size):
for j in range(i+1,size):
if(tup[i]==tup[j]):
print(tup[i],end="\t")