Skip to content

Instantly share code, notes, and snippets.

@gonzalezgarciacristian
Last active August 29, 2015 14:07
Show Gist options
  • Save gonzalezgarciacristian/1bee1216a4917f577e03 to your computer and use it in GitHub Desktop.
Save gonzalezgarciacristian/1bee1216a4917f577e03 to your computer and use it in GitHub Desktop.
Python: Diccionaries
__author__ = 'Cris'
import unittest
class Exam(unittest.TestCase):
def calculate_notes(self, solutions, all_answers):
pass
def test_exam_1(self):
self.exam_solution = {1: 'a', 2: 'b'}
self.students_answers = {1: {1: 'a', 2: 'a'}, 2: {1: 'c', 2: 'b'}, 3: {1: 'c', 2: 'c'}, 4: {1: 'a', 2: 'b'}}
self.assertDictEqual(self.calculate_notes(self.exam_solution, self.students_answers), {1: 0.75, 2: 0.75, 3: -0.5, 4: 2})
def test_exam_2(self):
self.exam_solution = {1: 'a', 2: 'b', 3: 'c'}
self.students_answers = {8: {1: 'a', 2: 'a', 3: ''}, 5: {1: 'c', 2: 'b', 3: 'a'}, 300: {1: 'c', 2: 'c', 3: 'c'}, 4: {1: 'a', 2: 'b', 3: 'c'}, 13: {1: 'a', 2: 'c', 3: 'c'}}
self.assertDictEqual(self.calculate_notes(self.exam_solution, self.students_answers), {8: 0.5, 5: 0.5, 300: 0.5, 4: 3, 13: 1.75})
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment