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
var firstNames = ['Alex', 'David', 'Peter', 'Tom', 'Shaun', 'Bill', 'Mary', 'Dan', 'Mark', 'Peter', 'Mikael', 'Sam', 'Tom', 'Fred', 'Robert', 'Martin', 'Peter']; | |
var lastNames = ['Michaels', 'Peterson', 'Jackson', 'Jones', 'Hank', 'Cruise', 'Radcliffe', 'Francis', 'Degroote', 'John', 'Jacobs']; | |
var ageList = [23,24,25,26,27,28,29,30,31,32]; | |
var cities = ["Delhi", "London", "Paris", "Singapore", "Beijing", "Colombo", "Mumbai"]; | |
var examTypes = ["homework", "exam", "quiz"]; | |
var courseType = ["full time", "part time"]; | |
function getRandom(list) { | |
return list[Math.floor(list.length * Math.random())]; |
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 pymongo import MongoClient | |
def remove_lowest_score(student): | |
homework_scores = filter(lambda x: x['type'] == "homework", student['scores']) | |
all_homework_scores = map(lambda x: x['score'], homework_scores) | |
min_homework_score = min(all_homework_scores) | |
all_scores = filter(lambda x: not(x['type'] == "homework" and x['score'] == min_homework_score), student['scores']) | |
db.students.update_one({"_id": student["_id"]}, {"$set": {"scores" : all_scores}}) | |
client = MongoClient() |
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
//Calculate average age of the students | |
var mapFunction = function(){ | |
emit("avgAge", this.age); | |
}; | |
var reduceFunction = function(age, values){ | |
return Array.sum(values) / values.length ; | |
}; |