Created
May 22, 2014 18:51
-
-
Save anna-is-cute/95126f6a964e48cfa9e4 to your computer and use it in GitHub Desktop.
ten.java points stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import loads | |
from urllib.request import urlopen | |
from statistics import mean, median, mode, stdev, variance | |
def getPointsList(transactions): | |
points = [] | |
for transaction in transactions: | |
points.append(transaction["amount"]) | |
return points | |
j = loads(urlopen("http://tenjava.com/api/points").read().decode("utf-8")) | |
data = getPointsList(j["recent_transactions"]) | |
print("Points: %s" % j["points"]) | |
print("Mean: %s" % mean(data)) | |
print("Median: %s" % median(data)) | |
print("Mode: %s" % mode(data)) | |
print("Std. dev.: %s" % stdev(data)) | |
print("Variance: %s" % variance(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment