Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ python main.py list
# Mark assignment as completed
python main.py complete "Math Homework"

# Delete an assignment
python main.py delete "Math Homework"

# Calculate your GPA
python main.py gpa

Expand All @@ -60,11 +63,14 @@ Added assignment: Physics Lab
$ python main.py add-assignment "History Essay" --deadline "2025-12-05" --subject "History"
Added assignment: History Essay

$ python main.py delete "Physics Lab"
Deleted assignment: 'Physics Lab'

$ python main.py stats
=== Your Statistics ===
Total Assignments: 2
Total Assignments: 1
Completed: 0
Pending: 2
Pending: 1
GPA: 0.00
```

Expand Down
13 changes: 11 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
def main():
parser = argparse.ArgumentParser(description='StudentHub - Manage your academic life')

parser.add_argument('command', choices=['add-assignment', 'list', 'complete', 'gpa', 'stats'],
help='Command to execute')
parser.add_argument('command', choices=['add-assignment', 'list', 'complete', 'delete', 'gpa', 'stats'],
help='Command to execute')
parser.add_argument('value', nargs='?', help='Value for the command')
parser.add_argument('--deadline', help='Deadline in YYYY-MM-DD format')
parser.add_argument('--subject', help='Subject name')
Expand Down Expand Up @@ -43,6 +43,15 @@ def main():
else:
print(f"Assignment '{args.value}' not found")

elif args.command == 'delete':
if not args.value:
print("Error: Please provide assignment title to delete")
return
if manager.delete_assignment(args.value):
print(f"Deleted assignment: '{args.value}'")
else:
print(f"Assignment '{args.value}' not found")

elif args.command == 'gpa':
gpa = manager.calculate_gpa()
print(f"Your current GPA: {gpa:.2f}")
Expand Down
8 changes: 8 additions & 0 deletions student_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def add_assignment(self, title, deadline, subject=None):
}
self.assignments.append(assignment)
return assignment

def delete_assignment(self, title):
"""Delete an assignment by title"""
for i, assignment in enumerate(self.assignments):
if assignment['title'] == title:
self.assignments.pop(i)
return True
return False

def list_assignments(self, show_completed=False):
"""List all assignments"""
Expand Down