Week 356 – June 22nd to June 28th

This was the worst week I’ve had working through the Computer Science section of KA so far. 😞 I only made it through a handful of videos and articles, and two challenges, and I didn’t make it through Unit 5. I’m fairly sure I spent at least 5 hours on KA, so it’s not like I wasn’t trying, but the challenges and project have gotten quite a bit harder from what they were before so I’m struggling to get through them. I had a mini epiphany which I’ll talk about at the end of this post that helped me make peace with the fact that I’m finding CS so difficult now. And the silver lining is that even though I didn’t do too well on KA, I did finish the CS50 video playlist — there were 10 two-hour lectures so I’m pretty happy about that — and I’ve been reading and working through the Automate the Boring Stuff with Python book. So, in total I’m guessing I likely studied for 15–20 hours this week. All in all, it definitely could have gone better but it also could have gone worse. (Story of my life. 🤷🏻‍♂️)

Here’s everything I made notes on this week:

Unit 5 – Automating Tasks with Lists

Lesson 3 – String Manipulation

Challenge: Reading Level

I started this challenge on Step 3 having made it through the first two steps at the end of last week. I had to use Gemini’s help for all three steps. 😔 I definitely got smoked on this challenge and it made me realize how out of my depth I am now, but I did get better at using methods and reading and writing code, so I’ve got that going for me which is nice. I can follow how variables flow through functions much better now after having worked through this challenge. I also know how to set up variables at the start of functions and update them as the function executes. Overall, I’m guessing spent around an hour on this challenge, so I’m at least happy with my effort even though I got smoked. 

Lesson 4 – List Mutation

Article – List Methods

This article went over the four list methods that you can see in the photo of my notes above. All the methods seem pretty intuitive to me. The article said there are a bunch of other methods, but when I clicked on the link it provided that was supposed to link to the other methods, I couldn’t find them on the page it took me to. 🤔

Video – Pass by Assignment

In this vid, Kim explained that unlike strings, integers, floats, and Booleans, when you pass a list into a function, if the function makes any changes to the elements in the list, it changes the OG list, not just a copy of the list. This is because strings, ints, floats, and Booleans are what’s called “immutable” (i.e. can’t be changed) whereas a list is “mutable” (meaning it CAN be changed). In her words, “[In a function] if your argument is a mutable type, any updates you make to the list parameter inside the function body carry over to the original variable you passed in.”

Article – Accumulator Pattern

This article talked about how when you need to use a list in a function, it’s often best to create a copy of the list IN the function and then update the copy so that other functions/people can use the OG list. You do this by using what’s called the “accumulator pattern” which starts with initializing what’s called an “accumulator value”, which is just an empty list (ex. list = []). Then you use a loop to iterate over the OG list and copy the updated element values into the accumulator value which holds the final result. The screenshot above shows three examples that were given in the article which I copied and pasted over into a separate IDE. The good news is that I feel like I can actually read these types of programs now, as in I can quickly and easily (ish) read through what’s happening in the functions instead of painstakingly trying to understand where the variables are going. This makes it a lot quicker now for me to understand what the function’s doing. 😮‍💨 (It’s sort of like how when you first learn how to read at school you first have to sound out each syllable, and then learn the different words, and then eventually you can just read sentences without having to stop and think.)

Exercise – Trace List Mutations

Question 1

Question 2

I got through this exercise in about 5 minutes. 😂 It was pretty easy but (as I keep repeating in these blog posts) it was still nonetheless worthwhile. It helped me better understand list methods and understand that you need to make a copy list, i.e. accumulator list, and helped me simply get better at reading and following along with Python code, in general.

Challenge: Order Forms

I REALLY struggled with this challenge and had to get Gemini to help me out with each step. 😒 In the first step (the second screenshot from above), I thought I had to write the function so that it would check each shirt size in each response — each response had a name, shirt size, and date, and some had a colour and monogram — and I assumed I had to create a variable for each size (xs, s, etc.) and += 1 that variable each time. I didn’t understand that in main.py (where the function was being called from) it said:

  • for size in[xs, s, m, l, xl]

which first looped ‘xs’ through the function, then ‘s’, etc. Gemini said each time the function looped it would check for each individual size in the response and, if the size matched, would add the entire response to a new list. Afterwards, the function in main.py would count how many entires there were IN the list and print(“Order ” + len(list) + “ xs green shirts”) and len(list) would put the integer into the print statement of how many responses there were in the accumulator list, i.e. how many shirts needed to be ordered.

The other two steps were just as tricky. Between all three steps, I had to get familiar with and figure out how to use the .split(), .lower(), .join(), .insert(), .append, and .upper() methods. I also did the end-of-challenge bonus step which gave me a bit of practice learning about and using dictionaries. I wouldn’t say I really figured out how to use a dictionary in Python (since I basically just copied what Gemini came up with), but I still think it was helpful for me to get a taste of how they work/how to use them. (And to give myself some credit, I did spend ~45 minutes trying to work through what Gemini’s suggested I do before looking at exactly how it told me I could write the code.)

Lesson 5 – Encrypting Messages

Project: Ciphers

Before I started this project, I read through all the modules to understand what was going on and how everything worked in the program. It  took me 20 minutes just to do this, spending ~10 minutes looking just at the shift_character function alone trying to understand how it worked. It took alphabet = [“abcdefghijklmnopqrstuvwxyz”], found each letter’s index with alphabet.index, shifted it by adding 17 to its index and finding the corresponding letter that was 17 indices away from the OG letter’s index. So, if a = 0, a + 17 = 17; 17 = r, therefore a + 17 turns into r. The modulo operator was also confusing to me. If alphabet [10] = j, alphabet[36 % 26] = 10 = j. If alphabet[1] = b , alphabet[1 % 26] = b.

I copy and pasted the instructions for this project into Gemini and got it to give me specific instructions for what I needed to do to satisfy the requirements of the project which you can see in the third screenshot above. I tried to figure out how to write the proper code for the first and second step Gemini gave me and got absolutely smoked… It was very demoralizing. I eventually “got through” all five steps, but only because after having gotten COMPLETELY stuck at each step, I asked Gemini what I needed to do and it gave me the answer… BUT, I probably spent ~20 minutes on each step trying to figure it out on my own, which I think helped me learn at least a little bit about calling lists, using list methods, etc. I was halfway through this project when the week came to an end, so I’ll pick back up where I left off this coming week.

I’m definitely disappointed that I couldn’t figure out how to write the code that Gemini suggested. 👎🏼 But it dawned on me — and this is the epiphany I was talking about — that what I’m trying to do is too big of a jumper me right now. I’m simply not ready to write this type of code. I don’t know how Python syntax works well enough yet. I realized that it would be like me trying to jump from the middle of arithmetic to the end of algebra, going from something like 6 x 8 to 23(4 – x) = 1, or something like that. The bottom line is that I need more practice writing simpler code before I can work through a project like this. I think it’s the same thing as when I was learning math in that I WILL be able to figure it out, I just need to take a step back and get a better handle on the fundamental concepts, and then I’ll eventually be able to come up with code like what Gemini suggested. 😤

And that was it for this past week. I think working through the book Automate the Boring Stuff with Python is really going to help me get a better grasp on the more basic Python syntax I was just talking about. So I’m hopeful that, although it will take me longer than I’d like it to, in the grand scheme of things it won’t take me too long to figure it out. I think this meta-skill of learning-to-learn which I learned and improved at while studying math will be SUPER helpful working through CS. It’s funny that the actual math I learned isn’t really all that applicable to CS — not yet, anyways — but the learning-to-learn skills I developed are definitely coming into practice. 

SO, fingers crossed (as always) that I can do a decent job this coming week wrapping my head around the some of the fundamental Python syntax that’s slowing me down so I can sooner-rather-than-later move on to bigger and better things! 🤞🏼

Leave a Reply

Your email address will not be published. Required fields are marked *