From 663768cdb7356cb7844d70ed31cf16527596d9b8 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Ragala Date: Mon, 5 Oct 2026 15:57:37 +0530 Subject: [PATCH] fix: correct the department average calculation in issue 70 --- python-open-source-challenge/issue-70.py | 27 +++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/python-open-source-challenge/issue-70.py b/python-open-source-challenge/issue-70.py index 970f69e..76f4484 100644 --- a/python-open-source-challenge/issue-70.py +++ b/python-open-source-challenge/issue-70.py @@ -1,25 +1,14 @@ -# ISSUE 70 -# -# Problem: -# Write a program that accepts daily task records containing completed and incomplete tasks and calculates the completion percentage for every day. -# -# This file contains an incomplete implementation. -# Do not rewrite the program from scratch. -# -# Find and repair the mistakes marked with TODO comments. -# -# After repairing the code, run this file and make sure all -# checks pass before submitting your Pull Request. - def completion_by_day(days): percentages = {} for day, tasks in days.items(): - # TODO: Check how completed tasks are counted. - completed = sum(tasks.values()) - 1 + # Count only completed tasks + completed = sum(tasks.values()) total = len(tasks) - # TODO: Check the denominator for a day's completion percentage. - percentages[day] = completed / (total + 1) * 100 if total else 0 - # TODO: Check that days with no tasks are retained. + + # Calculate percentage using the actual total number of tasks + percentages[day] = completed / total * 100 if total else 0 + + # Days with no tasks are retained as 0% return percentages def check_solution(): @@ -30,4 +19,4 @@ def check_solution(): print("All checks passed!") if __name__ == "__main__": - check_solution() + check_solution() \ No newline at end of file