You can find the median of all values in a python map
or dictionary using the statistics
module. Here's an example code snippet:
main.py329 chars14 lines
In the above code, we first import the statistics
module. Then we create a sample map called my_map
. We get all the values from the map using the .values()
method, and store them in a variable called values
. Finally, we calculate the median of the values using the statistics.median()
method, and print out the result.
gistlibby LogSnag