CBSE Class 11 Computer Science Question 33 of 42

Practice Paper — Question 5

Back to all questions
5
Question

Question 28(b)

Write a program to check if the smallest element of a tuple is present at the middle position of the tuple.

Solution
tup = (5, 9, 1, 8, 7)
smallest = min(tup)
middle_index = len(tup) // 2
if tup[middle_index] == smallest:
    print("The smallest element is at the middle position.")
else:
    print("The smallest element is NOT at the middle position.")
Output
The smallest element is at the middle position.
Answer