Q. Write a program to input n numbers from the user. Store these numbers in a tuple. Print the maximum and minimum number from this tuple.

 


You can understand by Watching video :-



Answer = 

 

tup= ()

while True :
      num = int(input("Enter a number :- "))
      tup += (num,)
      user = input("Do you want to quit enter yes =")
      if user == "yes":
            print(tup)
            print("Max :-",max( tup ))
            print("Min :-",min( tup ))
            break

Output :-

Enter a number :- 9
Do you want to quit enter yes =no
Enter a number :- 7
Do you want to quit enter yes =no
Enter a number :- 6
Do you want to quit enter yes =no
Enter a number :- 2
Do you want to quit enter yes =no
Enter a number :- 8
Do you want to quit enter yes =yes
(9, 7, 6, 2, 8)
Max :- 9
Min :- 2

>>>

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post