Python Program to Find Smallest and Largest Element From Tuple
my_tuple=tuple(map(int,input("Enter tuple data items:").split()))
smallest=min(my_tuple)
largest=max(my_tuple)
print("The smallest element from tuple is:",smallest)
print("The largest element from tuple is:",largest)
Output:
Enter tuple data items:1 3 7 90 23 0
The smallest element from tuple is: 0
The largest element from tuple is: 90
Python Program to Find Smallest and Largest Element From Tuple
my_tuple=tuple(map(int,input("Enter tuple data items:").split()))
min_val=my_tuple[0]
max_val=my_tuple[0]
for i in my_tuple:
if isinstance(i,int):
if i<min_val:
min_val=i
if i>max_val:
max_val=i
print("The smallest element from tuple is:",min_val)
print("The largest element from tuuple is:",max_val)
Output:
Enter tuple data items:1 2 34 56 89 90
The smallest element from tuple is: 1
The largest element from tuuple is: 90
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏