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

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad