Skip to content

Instantly share code, notes, and snippets.

@RamiAwar
Created October 2, 2021 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RamiAwar/fb7d9868c139b17fc56fa9891037f1db to your computer and use it in GitHub Desktop.
Save RamiAwar/fb7d9868c139b17fc56fa9891037f1db to your computer and use it in GitHub Desktop.
def calculate_stats(exam_results: List[int]) -> Dict[str, float]:
max_score = max(exam_results)
min_score = min(exam_results)
avg_score = sum(exam_results) / len(exam_results)
return {"max": max_score, "min": min_score, "avg": avg_score}
def post_exam_computation(exam_id):
exam_results = db.get(exam_id)
exam_stats = calculate_stats(exam_results)
db.save(exam_stats)
def test_calculate_stats():
exam_results = [1, 2, 3]
stats = calculate_stats(exam_results)
assert stats["max"] == 3
assert stats["min"] == 1
assert stats["avg"] == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment