rator (e.g., lst1 + lst2) • the list replication operator (e.g., lst * n or n * lst) • Python's built-in len, min and max functions, unless otherwise noted. Your solutions cannot use: • list slicing (e.g., lst[i : j] or (lst[i : j] = t)
Automated testing is required
Your solutions can use:
• the [] operator to get and set list elements (e.g., lst[i] and lst[i] = a)
• the in and not in operators (e.g., a in lst)
• the list concatenation operator (e.g., lst1 + lst2)
• the list replication operator (e.g., lst * n or n * lst)
• Python's built-in len, min and max functions, unless otherwise noted.
Your solutions cannot use:
• list slicing (e.g., lst[i : j] or (lst[i : j] = t)
• the del statement (e.g., del lst[0])
• Python's built-in reversed and sorted functions.
• any of the Python methods that provide list operations, e.g., sum, append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort
• list comprehensions
using python language Use the function design recipe to develop a function named max_occurrences. The function takes a list of integers, which may be empty. The function returns value of the maximum occurrences in a given list. For example, when the function’s argument is [2, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2], the function returns the value that has the maximum occurrences, which in this case is 2. You can assume there will not be two values with the maximum number of occurrences, that means [2,2,6,6] will not happen.
For this exercise, you are allowed to use the method “count”
Step by step
Solved in 2 steps with 1 images