title: In Python Statistics mean and median, how the output type is defined?
body: <p>I'm learning python and trying basic functions as creating variables, doing some maths, messing with lists, and using statistics function. However, while experimenting statistics.mean() and statistics.median() I could see a patern of the output variable type.</p>
  <p>As two examples, I run the code below twice, just including one element on the list:</p>
  <pre><code>from statistics import mean, median
  z = [10,20,30,40]
  x = mean(z)
  y = median(z)
  print(x)
  print(type(x))
  print(y)
  print(type(y))
  </code></pre>
  <p>The output was:</p>
  <pre><code>25
  &lt;class 'int'&gt;
  25.0
  &lt;class 'float'&gt;
  </code></pre>
  <p>Then, I run the code again</p>
  <pre><code>from statistics import mean, median
  z = [10,20,30,40,11]
  x = mean(z)
  y = median(z)
  print(x)
  print(type(x))
  print(y)
  print(type(y))
  </code></pre>
  <p>And the output was</p>
  <pre><code>22.2
  &lt;class 'float'&gt;
  20
  &lt;class 'int'&gt;
  </code></pre>
  <p>Is there a rule to know, or a &quot;best practice&quot; to follow and prevent further problemas in the future?</p>