Find the maximum value from a tuple

In this python tuple program, we will find the maximum value from a tuple.

Steps to solve the program
  1. Create a tuple.
  2. Find the maximum value from a tuple using max().
  3. Print the output.
				
					tup = (41, 15, 69, 55)
print("Maximum value: ",max(tup))
				
			

Output :

				
					Maximum value:  69
				
			
Solution2 :
				
					# take input tuple with multiple values
tup = (41, 15, 69, 101, 55)
# initiate a variable to store max value
max_val = 0
# interate through tuple values using loop
for val in tup:
    # check if val is greater than max_val
    if val > max_val:
        # assign variable value to max_val.
        max_val = val
    else:
        continue

print("maximum value :", max_val)
				
			

Output :

				
					maximum value : 101
				
			

create a tuple with 2 lists of data.

find the minimum value from a tuple.

1 thought on “Find the maximum value from a tuple”

Leave a Comment