code: def avg(self, key=None):
          
          count = self.count()
  
          if count:
              return self.sum(key) / count
docs: Get the average value of a given key.
  
          :param key: The key to get the average for
          :type key: mixed
  
          :rtype: float or int