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
>>>>
question is wrong.
ReplyDeleteTell me the correct one.
Deletebook has changed
ReplyDeleteTell me the Edition you have.
DeleteThis is according to 2020-21 Edition.
The question is " Write a program to store roll number, name and marks of students.
ReplyDeletePlease go to this link https://www.pathwalla.com/2020/10/write-program-to-create-nested-tuple-to.html
DeleteU are providing us the best. Thank u so much
ReplyDeleteWelcome : )
DeleteWhere is output
ReplyDeleteOk, I have written it.
Deleteif we deleted the second "for i in range" line and wrote elif instead would that make any difference ?
ReplyDeleteThen program will not give desired output.
DeleteWrite a Program to check a mode of a tuple
ReplyDeleteDo it by importing Statistic library.
DeleteHi
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )