PYTHON QUESTION:
- Write the body of a function most_ending_digit(L) thatconsumes a non-empty list of natural numbers L and return thesingle digit that occurs most frequently at the end of the numbersin the list. The function returns the smallest digit in the case ofa tie. Your function should run in O(n) time. Do not mutate thepassed parameter.
def most_ending_digit(L)
'''
Returns the single digit that occurs most frequently
as the last digit of numbers in L. Returns the
smallest in the case of a tie.
 Â
most_ending_digit: (listof Nat) -> Nat
Requires: len(L) > 0
 Â
Examples:
most_ending_digit([1,2,3]) => 1
most_ending_digit([105, 201, 333,
995, 9, 87, 10]) => 5
'''
## CODE
- Write the body of a function __eq__ method for this class thatreturns True if the two objects compared are Movie objects eachhaving the same fields and False otherwise.
class Movie:
'''
Fields:
name (Str),
year (Nat),
rating (Nat)
'''
def __init__(self, n, y, r):
self.name = n
self.year = y
self.rating = r
 Â
def __eq__(self, other):
'''
Returns True if the movies are equal
 Â
__eq__: Movie Any -> Bool
'''
##CODE