The function named `freq(l)` that takes a list `l` of numbers and returns a tuple of the most frequent number and its frequency is as follows;
def freq(l):
s = { x for x in l }
lt = [ (x, l.count(x)) for x in s ]
mn = max(lt,key=lambda item:item[1])[1]
r = ([ x for (x,v) in lt if v == mn], mn)
return r
print(freq([1,2,3,4,5,2,3,4,5,3,4,5,4,5,4]))
Code explanation;
The code is written in python.
- we defined a function named "freq" and it accept an argument named l.
- The second line we get the unique values using sets.
- The variable "lt" is use to store list of tuple containing unique values and their occurrences in the list.
- "mn" is a variable use to store the maximum number of occurrences.
- Then, the variable r is use to store the resulting tuple, filtering out all the items with less occurrences than the maximum.
- we returned the variable "r".
- Then we call our function with the parameter.
learn more on python here: https://brainly.com/question/4503928