[issue35698] Division by 2 in statistics.median
Jonathan Fine
report at bugs.python.org
Thu Jan 10 11:29:18 EST 2019
Jonathan Fine <jfine2358 at gmail.com> added the comment:
Here's the essence of a patch.
Suppose the input is Python integers, and the output is a mathematical integer. In this case we can make the output a Python integer by using the helper function
>>> def wibble(p, q):
... if type(p) == type(q) == int and p%q == 0:
... return p // q
... else:
... return p / q
...
>>> wibble(4, 2)
2
>>> wibble(3, 2)
1.5
This will also work for average.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35698>
_______________________________________
More information about the Python-bugs-list
mailing list