Skip to content

add code for assignment 1#1

Open
feeza2025 wants to merge 1 commit intomainfrom
assignment-1
Open

add code for assignment 1#1
feeza2025 wants to merge 1 commit intomainfrom
assignment-1

Conversation

@feeza2025
Copy link
Copy Markdown
Owner

@feeza2025 feeza2025 commented Nov 30, 2025

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

Adding code for the two anagram_checker subroutines (one with an extra paramter for is_case_sensitive) for assignment_1.ipynb. I also added few extra test cases.

What did you learn from the changes you have made?

I learnt more about creating functions using python. I used the Docstring I learnt in class to add description about the function. This is the first time I am learning that we could create those convenient function descriptions. I also learnt that python use the word strip for trimming string, many other programming languages would use the word trim. I also learnt to use other string functions such as lower() for lowercase and len to check the length. The len function was different because it took the string as an argument and the lower() seems to be a method associated with the string. I also gained practise with sorted and the array function join. I am not sure how much more or less performant they are as compared to using loops and key-value pairs, but they definitely kept the code more concise and readable, as opposed to using loops.

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

I was first thinking about using loops and key value pairs to look up each letter count. However, sorted and join helps to keep the code more concise and clean. I am not sure which technique is more efficient in terms of runtime and memory usage.

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

At work I mostly use Perl. Python is a shift. There are some similarities, but there are also differences. I have to remember to keep the difference in mind. To overcome some of my challenges, I would google how to do 'x' in python, for example, how to trim a string in python. I was also not too sure how to confirm if my changes were correct, but the list of test case code snippets in the notebook helped a lot. I also added some extra. I think have an auto-grader for this assignment would also be really helpful to help us confirm if we are on the right track. It will definitely help with grading anxiety!

How were these changes tested?

I ran the code snippets that called the function and check to confirm if the output match the output stated in the comment.

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

Checklist

  • I can confirm that my changes are working as intended

Copy link
Copy Markdown

@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. Great extra test cases. Assignment 1 is complete – no changes needed.

Just a couple minor suggestions for future improvement:

  • In places like:
  if(word_a != word_b):
    return False

  return True

You can simplify this by directly returning the boolean expression:
return word_a == word_b
This makes the code cleaner

  • Very minor: No need to join the sorted strings unless you’re comparing strings instead of lists — but comparing lists directly is fine.

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