nodes: 0, module; 1, function_definition; 2, function_name:percentile; 3, parameters; 4, block; 5, identifier:data; 6, identifier:n; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, comment:"""Return the n-th percentile of the given data
  
      Assume that the data are already sorted
  
      """; 13, assignment; 14, assignment; 15, boolean_operator; 16, block; 17, subscript; 18, identifier:size; 19, call; 20, identifier:idx; 21, binary_operator:(n / 100.0) * size - 0.5; 22, comparison_operator:idx < 0; 23, comparison_operator:idx > size; 24, raise_statement; 25, identifier:data; 26, call; 27, identifier:len; 28, argument_list; 29, binary_operator:(n / 100.0) * size; 30, float:0.5; 31, identifier:idx; 32, integer:0; 33, identifier:idx; 34, identifier:size; 35, call; 36, identifier:int; 37, argument_list; 38, identifier:data; 39, parenthesized_expression; 40, identifier:size; 41, identifier:StatisticsError; 42, argument_list; 43, identifier:idx; 44, binary_operator:n / 100.0; 45, call; 46, identifier:n; 47, float:100.0; 48, attribute; 49, argument_list; 50, string:"Too few data points ({}) for {}th percentile"; 51, identifier:format; 52, identifier:size; 53, identifier:n
code: def percentile(data, n):
      """Return the n-th percentile of the given data
  
      Assume that the data are already sorted
  
      """
  
      size = len(data)
      idx = (n / 100.0) * size - 0.5
  
      if idx < 0 or idx > size:
          raise StatisticsError("Too few data points ({}) for {}th percentile".format(size, n))
  
      return data[int(idx)]