<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def avg(self, key=None):
 """ Get the average value of a given key. :param key: The key to get the average for :type key: mixed :rtype: float or int """

        count = self.count()

        if count:
            return self.sum(key) / count