-
-
Save RamiAwar/fb7d9868c139b17fc56fa9891037f1db 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
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