Created
October 17, 2015 23:16
-
-
Save ndmanvar/955743af58ef67901a7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
import json | |
# limit = 379 for now. Alex must change | |
r = requests.get('https://api.clever.com/v1.1/sections?limit=379&where=%7B%22district%22%3A%224fd43cc56d11340000000005%22%7D&distinct=district%2Cstudents%2Ccourse_name%2Csis_id', headers={'Authorization':'Bearer DEMO_TOKEN'}) | |
# putting r.text (string) into as json object (json_obj) | |
json_obj = json.loads(r.text) | |
# initialize total_students to 0. | |
# keep adding to this | |
total_students = 0 | |
total_num_sections = len(json_obj['data']) | |
for section in json_obj['data']: | |
num_students = len(section['students']) | |
# total_students = total_students + num_students | |
total_students += num_students | |
avg_num_students = total_students / total_num_sections | |
print "average number of students per section is : %i" % avg_num_students |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment