Q. Write a program to check the mode of a tuple is actually an element with maximum occurrences.

 

Answer =

 

tup = eval(input("Enter a tuple :-"))
count = 0
for i in tup :
      if count <  tup.count(i):
            count = tup.count(i)

for i in tup :
      if count == tup.count(i) :
            print("mode = ",i)
            break



Output :-


Enter a tuple :-(1,5,4,8,7,5,4,3,8,0,5,4,2)
mode = 5

>>>>

15 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post