Computer Science
Write a program to check if the smallest element of a tuple is present at the middle position of the tuple.
Python
Python Tuples
1 Like
Answer
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.
Answered By
2 Likes
Related Questions
Explain the given built-in string functions and provide the syntax and example of each.
(a) replace()
(b) title()
(c) partition()
Write a program to count the frequency of a given element in a list of numbers.
What are the characteristics of Dictionary?
What are the issues associated with disability while teaching and using computers?