Programming Examples
Python program to find maximum and minimum values in tuple
Write a program to input ‘n’ numbers and store it in a tuple and find maximum & minimum values in the tuple.
Solution
t=tuple()
n=int(input("Total number of values in tuple"))
for i in range(n):
a=input("enter elements")
t=t+(a,)
print ("maximum value=",max(t))
print ("minimum value=",min(t))
Output/ Explanation:
Total number of values in tuple5
enter elements3
enter elements4
enter elements5
enter elements6
enter elements2
maximum value= 6
minimum value= 2