Binary Search Algorithm

No BS: It is important to try and implement known ‘easy’ algorithms as it provides practice on working towards trickier algorithms, as well as translating human instructions into a usable program. With BS: Working through Exercise 20 of, you are tasked to implement the Binary Search Algorithm for a sorted list of numerical integers, […]

Read more "Binary Search Algorithm"

Basic Exceptions

No BS: using a ‘while True’ loop and a ‘continue’ line in an exception is good because it gives the user another go at an input (if that’s what it was used for) without having to go through the whole program again.   With BS: So I just put together a quick program to check […]

Read more "Basic Exceptions"

Word/Count Dict (Part 2)

No BS: Previous code didn’t strip out punctuation and left us with weird duplicates of words. For example, “the”, “the–“, and “(the” would all be considered separate words. I added a piece of code to strip out the punctuation which was: out = s.translate(str.maketrans(”, ”, string.punctuation)) I then sorted the words based on the output […]

Read more "Word/Count Dict (Part 2)"