CBSE Class 11 Computer Science Question 101 of 114

Tuples — Question 4

Back to all questions
4
Question

Question 3

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.

Solution
n = eval(input("Enter the numbers: "))

tup = tuple(n)

print("Tuple is:", tup)
print("Highest value in the tuple is:", max(tup))
print("Lowest value in the tuple is:", min(tup))
Output
Enter the numbers: 3,1,6,7,5
Tuple is: (3, 1, 6, 7, 5)
Highest value in the tuple is: 7
Lowest value in the tuple is: 1
Answer