Week 354 – June 8th to June 14th

I didn’t get through nearly as much material on KA this week as I was hoping to, BUT I’d still say that I had quite a productive week and learned a lot. I only made it through 4.5 lessons but likely spent 10–15 hours working on KA in total, not to mention all the other stuff I’ve been doing to learn CS like watching the CS50 and other supplementary videos on CS, and reading Code and a new book called Automate the Boring Stuff with Python. That said, I am disappointed I didn’t make it through Unit 5 but, just like with math, obviously what’s more important is that I’m learning as much as possible as opposed to rushing through the material without retaining anything. So, all in all, I’m happy with my effort this week even though I’m disappointed it’s taking me longer to get through this course than I anticipated. (What else is new…)

The first thing I started on this week was the challenge from Lesson 2 of Unit 4, Playing Games with Functions:

Unit 4 – Playing Games with Functions

Lesson 2 – Function Control Flow

Challenge: Sweet Scores

This challenge wasn’t too difficult, but each step did take me a few minutes to understand. Once I figured out what each step was asking me to do, it usually took me ~2 minutes to write the code. At the end it suggested I come up with another function that would take in the number of mango cards (lol) a player got and if it was an even number, it would return the number of cards x3, and if it was odd, it would return 0. I figured I should use the % operator which, after asking CGPT, turned out to be the right thing to do, but I initially didn’t write out the code properly (which is why I had to use CGPT…). I can’t remember what I wrote initially but remember that I wasn’t too far off. The proper was to write the code was:

  1. If num_mangos % 2 != 0:
  2.      […the rest of the code]

(Also, I like how you can more-or-less say line 1 above out loud and it makes sense – “If the remainder of the number of mangos divided by 2 doesn’t equal 0, execute this code.”)

The next thing I made notes on was the second video in the third lesson:

Lesson 3 – Code Organization

Video – Program Design: Nim Game

In this video, Kim worked through an example of creating a game where it’s the user VS the computer and they each picked either one or two stones from ten and, whoever picked the last stone lost. I spent ~30–40 minutes creating the game in my own IDE alongside her which was pretty helpful just to get practice writing out functions, connecting variables, importing modules, etc. In a certain sense, I didn’t learn as “well” as I would have if I did it by myself, but the truth is I wouldn’t have been able to do it by myself anyways, so I think just copying what she wrote out was still helpful, nonetheless.

Th next thing I did was the challenge from that lesson:

Challenge: Rock, Paper, Scissors

This challenge took me a long time to get through, partly because I wasn’t sure how to write the code for each step, but also because the instructions were vague/confusing to me. The first step asked me to make the computer’s choice between “rock”, “paper”, or “scissors” random which seemed easy and which I thought I did properly. However, when I did it and clicked Run, KA didn’t say Step 1 was complete. I went back and forth with CGPT for about 30 minutes trying to figure out what I was doing wrong and, in the end, all I needed to do was play out the game of Rock, Paper, Scissors in the console for the step to be marked as “complete”… 😕 It didn’t say to do this in the instructions though which was super annoying. I’m not going explain the details but the next two steps were also tricky and took me 10–15 minutes each to complete.

After that, I got started on the fourth lesson which was all about testing your code:

Lesson 4 – Testing

Article – Test Cases

This article explained what testing is in programming. (In the video before this article, Kim said there’s something called “unit testing” which I think is basically the same thing as what this article talked about but means testing for individual functions, specifically. I could be wrong about that though.) In KA’s words, “A test case describes a specific scenario to validate. With functions, a test case typically defines a set of arguments and the expected return value.”

 The next thing I made notes on was the exercise from this lesson:

Exercise – Identifying Test Cases

Question 1

Question 2

This exercise was pretty simple. I’m not going to bother explaining how the questions worked because it’s pretty obvious, but I will say that the second question above was helpful for me to think through how the return operator exits the conditional immediately. 

The next thing I did was the challenge from this lesson which ended up being pretty hard:

Challenge: Dice 21

For the second step of this challenge, I couldn’t make sense of the code and didn’t understand that as it was written, if the user went over 21 and the computer didn’t (ex. user == 23 and computer == 20) the program would still output “user” wins. I asked CGPT what I was doing wrong and it explained what was going on, but then when I added in the appropriate conditions, I set them below the OG conditions which meant that the function would exit the loop body immediately when the user was >21 and the computer stopped and would state “user” wins. (I’m sure what I just wrote doesn’t make sense, but I don’t know how to explain it. Also, I’m still pretty confused as to what happened with the code, but the bottom line was that when I moved the conditions I wrote to the top of the function body, it worked.) As the end, I asked CGPT to explain what happened and it said in scenarios like this, whenever there are special conditions, the always go at the start:

After that, I got started on the final project of this unit which ended up taking me two days to finish:

Lesson 5 – Designing Levels

Project: Timed Typer

Over Thursday and Friday, I probably spent 3–4 hours on this project going back and forth with CGPT on how to write the code. Like last week, I got CGPT to act as a tutor, not giving me the answers but “bread-crumbing” me to the solutions. The main thing I had to do was write functions (which aren’t shown in the screenshot above — they were in the typer.py module you can see in the tab beside main.py in the screenshot). There were 80 lines of code in typer.py which I know isn’t a lot but it’s the most I’ve written so far. I asked CGPT to summarize what I did throughout the project and it said something along the lines of:

  • “In this project I designed a multi–level speed typing program. I had to create a level system that increased in difficulty by changing the number of words and their difficulty, and reduce the amount of time users had to type each word as they progressed through each level. I had to write several functions, passing information between them using parameters and return values. One concept I learned was that a function can return multiple values at once. [ I believe this is called a “tuple”.] I also got better at using conditional statements to control the game flow and the end of the game display messages.”

After that, I finally got started on the fifth unit, Automating Tasks with Lists, on Saturday:

Unit 5 – Automating Tasks with Lists

Lesson 1 – List Indices

Videos 1 & 2 – Scripts and Sequences / Lists

Above are screenshots from the first two videos of this unit. In the first video, Kim introduced what are called scripts which, from what I understand, are little, individual programs, and in the second video she talked about lists which are basically the same thing as arrays in the programming language C. As far as I understand, lists are just groups of data which could be integers, strings, etc. 

The last thing I got to this week was the article from that first lesson:

Article – List Indexing

This article went into more details about lists. Lists typically use “zero” indexing which just means that the address (?) of the first datum in the list is 0, the second address is 1, etc. This “makes sense” to me, as in I understand how it works, but I wonder why they don’t just start it at 1. “Negative” indexing also “makes sense” to me, but I also wonder when/why it’d be preferable over zero indexing. Nonetheless, lists seem like they’ll be super useful and I’m guessing will be used quite a bit in Python. The concept of lists is kind of interesting to me. I don’t think they’ll be that hard for me to wrap my head around, but I know that I’ll need to write out the code for them a lot before I remember how to use them.

And that was it for this week. Overall, I think I did pretty well and am happy with my effort. As I mentioned, I also did a lot of other, non-KA related studying. When I was reading the book Automate the Boring Stuff with Python, it told me to download a code editor (which is not the same thing as an IDE but it’s similar) called Mu and when I asked CGPT and Gemini how it worked, they both said I could download what’s called Visual Studio Code instead, which is a slightly more advanced code editor but is apparently the one that a lot of professionals actually use. I downloaded it and have watched a few tutorial videos on how it works and, even though I don’t really know what’s going on yet, I’m excited that I’m on the verge of being able to write code like a professional! (Or at least, I’m on the verge of learning how to write code like a pro/using the same software as pros…) So although I’m sure that I’ve only taken a few steps on what will end up being quite a long journey, I’m becoming more and more pumped by the week to learn how to program.

So, as always, fingers crossed I have a productive upcoming week and make some decent progress making it through this first CS course, a.k.a. the first chapter of me learning how to program! 🤞🏼🤓