Return the average number of courses per string.
321324
def count_courses(self):
        """"""
        c = 0
        for x in self.tuning:
            if type(x) == list:
                c += len(x)
            else:
                c += 1
        return float(c) / len(self.tuning)
669881
def average_current(self):
        
        len_data_pt = len(self.data_points)
        if len_data_pt == 0:
            return 0
        cur = sum(self.data_points) * 1000 / len_data_pt
        return round(cur, self.sr)
1311165
public function get_courses_count($options = array()) {
        $cntcachekey = 'lcnt-'. $this->id. '-'. (!empty($options['recursive']) ? 'r' : '');
        $coursecatcache = cache::make('core', 'coursecat');
        if (($cnt = $coursecatcache->get($cntcachekey)) === false) {
            // Cached value not found. Retrieve ALL courses and return their count.
            unset($options['offset']);
            unset($options['limit']);
            unset($options['summary']);
            unset($options['coursecontacts']);
            $options['idonly'] = true;
            $courses = $this->get_courses($options);
            $cnt = count($courses);
        }
        return $cnt;
    }
1145255
def avg(self):
        """"""
        # XXX rename this method
        if len(self.values) > 0:
            return sum(self.values) / float(len(self.values))
        else:
            return None
189059
def count_end(teststr, testchar):
    """"""
    count = 0
    x = len(teststr) - 1
    while x >= 0 and teststr[x] == testchar:
        count += 1
        x -= 1
    return count
199614
def average(arr):
  
  if len(arr) == 0:
    sys.stderr.write("ERROR: no content in array to take average\n")
    sys.exit()
  if len(arr) == 1:  return arr[0]
  return float(sum(arr))/float(len(arr))
139651
public function count_grades() {
        global $DB;

        if (!$this->has_instance()) {
            return 0;
        }

        $currentgroup = groups_get_activity_group($this->get_course_module(), true);
        list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true);

        $params['assignid'] = $this->get_instance()->id;

        $sql = 'SELECT COUNT(g.userid)
                   FROM {assign_grades} g
                   JOIN(' . $esql . ') e ON e.id = g.userid
                   WHERE g.assignment = :assignid';

        return $DB->count_records_sql($sql, $params);
    }
1039655
public String getRandomPassword(int countTotal, int countCapitals, int countSpecials) {

        String res = "";

        String[] Normals = ArrayUtils.addAll(ArrayUtils.addAll(Capitals, Letters), Numbers);
        Random rand = new Random();
        for (int i = 0; i < (countTotal - countCapitals - countSpecials); i++) {
            res = res + Normals[rand.nextInt(Normals.length)];
        }
        for (int i = 0; i < countSpecials; i++) {
            int pos = rand.nextInt(res.length());
            res = res.substring(0, pos) + Specials[rand.nextInt(Specials.length)] + res.substring(pos);
        }
        for (int i = 0; i < countCapitals; i++) {
            int pos = rand.nextInt(res.length());
            res = res.substring(0, pos) + Capitals[rand.nextInt(Capitals.length)] + res.substring(pos);
        }
        return res;
    }
371938
private static int totalSyllables(String strText) {
        int intSyllableCount = 0;
        
        List<String> arrWords = (new WhitespaceTokenizer()).tokenize(strText);
        int intWordCount = arrWords.size();
        for (int i = 0; i < intWordCount; ++i) {
            intSyllableCount += syllableCount(arrWords.get(i));
        }
        return intSyllableCount;
    }
702394
private int calcCountSubstringsWords(String str, HashSet<String> words) {
    int wordCount = 0;
    int N = str.length();
    for (int i = 0; i < N - 1; i++)
      for (int j = i + 2; j < N + 1; j++) {
        if (words.contains(str.substring(i, j)))
          wordCount += 1;
      }
    return wordCount;
  }
11611
function avg(input, output) {

  var event = input[0];
  if (event.what === 0 && event.total === 0) {
    return [];
  }
  return [ output, [ 'total', cyan + event.what.toFixed(3) + close ],
    [ 'average', cyan + (event.what / event.total).toFixed(3) + close ],
    [ 'max', cyan + event.max.toFixed(3) + close ],
    [ 'min', cyan + event.min.toFixed(3) + close ], [ '' ] ];
}
1247868
def _get_rating(self, entry):
        """"""
        r_info = ''
        for string in entry[2].strings:
            r_info += string
        rating, share = r_info.split('/')
        return (rating, share.strip('*'))
316064
def number_of_sections(self):
    """"""
    if not self._is_parsed:
      self._Parse()
      self._is_parsed = True

    return len(self._sections)
1169652
def convertstatsmethod(method_str):
        """"""
        if StringClass.string_match(method_str, 'Average'):
            return 'ave'
        elif StringClass.string_match(method_str, 'Maximum'):
            return 'max'
        elif StringClass.string_match(method_str, 'Minimum'):
            return 'min'
        elif method_str.lower() in ['ave', 'max', 'min']:
            return method_str.lower()
        else:
            return 'ave'
333222
def num_examples(self):
        """"""
        if self.is_list:
            return len(self.list_or_slice)
        else:
            start, stop, step = self.slice_to_numerical_args(
                self.list_or_slice, self.original_num_examples)
            return stop - start
763647
def get_average_record(self, n):
        
        history_deque = collections.deque()
        averages = []
        for d in self.data_points:
            history_deque.appendleft(d)
            if len(history_deque) > n:
                history_deque.pop()
            avg = sum(history_deque) / len(history_deque)
            averages.append(round(avg, self.lr))
        return averages
1264167
def get_course_list_name(curriculum_abbr, course_number, section_id,
                         quarter, year):
    
    return "%s%s%s_%s%s" % (
        _get_list_name_curr_abbr(curriculum_abbr),
        course_number,
        section_id.lower(),
        quarter.lower()[:2],
        str(year)[-2:]
        )