Skip to content

UofT-DSI | python - Assignment 1#1

Open
akorade wants to merge 2 commits intomainfrom
assignment-1
Open

UofT-DSI | python - Assignment 1#1
akorade wants to merge 2 commits intomainfrom
assignment-1

Conversation

@akorade
Copy link
Owner

@akorade akorade commented Nov 26, 2025

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

I implemented an anagram checker function in two parts:

  • Part 1: Created a basic anagram checker that compares two words case-insensitively
  • Part 2: Extended the function to support case-sensitive comparison by adding an is_case_sensitive boolean parameter

What did you learn from the changes you have made?

  • How to use the sorted() function to normalize strings for comparison
  • The importance of the lower() method for case-insensitive string comparison
  • How to use conditional logic (if not) to handle boolean parameters
  • That sorting letters converts a string into a list of characters, which can be compared directly

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

I considered using a dictionary to count character frequencies instead of sorting, but decided sorting was simpler and more concise. Another approach could have been using Counter from the collections module:

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

NA

How were these changes tested?

I tested the changes locally using Jupyter Notebook in Visual Studio Code. I ran all code cells in the notebook assignment_1.ipynb

A reference to a related issue in your repository (if applicable)

NA

Checklist

  • I can confirm that my changes are working as intended

Added an anagram_checker function with case-insensitive and case-sensitive options. Updated notebook cells to include function implementation, test cases, and outputs. Changed kernel metadata to use Python 3.12.10.
Simplified the anagram_checker function by normalizing case at the start if case sensitivity is disabled, then sorting both words. This improves readability and reduces code duplication.
Copy link

@xindizhang xindizhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! Your code is clean and well-written and your PR description is clear. Assignment 1 is complete – no changes needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants