Week 351 – May 18th to May 24th

I’m happy to say that my second week studying CS was a productive one! I made it through a TON of videos, exercises, and challenges on KA but, to be fair, they were all pretty easy. I spent a lot of time this week watching the CS50 vids and reading Code, so in total I’m guessing I studied CS for 25-35 hours, so I’ve at least got that going for me which is nice. And even though most of what I worked on in KA was “easy”, I still learned some pretty useful stuff. The way I see it, it’s similar to math where you have to first start by learning arithmetic which algebra builds on, which trig builds on, etc. So, even though what I’m working on seems incredibly simple right now (to the point where it almost seems unnecessary), I’m certain that I’m learning fundamental concepts which I’ll be using to build more complex programs on top of. But all in all, I’m very happy with my effort this week and with how much material I was able to get through and am hoping to keep this pace up moving forward! 💪🏼

The first thing I started with this week was what’s called a Project which was the final thing I had to do in the first unit of Intro to Computer Science – Python, Computational Thinking with Variables. Here are some screenshots from the project:

Intro to Computer Science – Python – Unit 1 – Project: Profile Page

I should mention that before I started this project, there was an article that talked about HTML code and said that HTML is a string that defines the structure and layout of a webpage. When you visit a webpage, the browser renders the HTML string (which is sort of like code) as the webpage. As you can see from the screenshots above, that’s basically what this project was all about; getting me to create a program that would ask the user for input that, when run, would output an HTML string that could be rendered as a very rudimentary looking HTML “profile” page. This project got me to come up with a few more questions to ask the user — I went with DOB and “Tell me a bit about yourself: ” — and then put those variable into the Python program to output the HTML string with those variables included. In the third screenshot above, you can see that KA also gave me an HTML IDE to input my code into to see if it worked properly.

One thing I didn’t like about the Project format (at least compared to Math) was that at the end when I was submitting my “answer”, it was just a self-reported questionnaire. It basically just said, “Did you do x? Did you do y?” I like the Math unit tests and Course Challenges more where they TOLD me if I did it correctly or not. But nonetheless, it was still really good practice doing this project and figuring out how to use Python to generate this rudimentary HTML string by getting user input.

After I got through that project, I then got started on Unit 2, Designing Algorithms with Conditionals. Here’s a little exercise I did in one of the first articles:

As you can see, this exercise was about Booleans. It was simple but actually pretty helpful as I got dog >= cat wrong initially thinking that cat > dog because it’s first alphabetically. That’s not how it works though. I’m assuming it’s something like the letters a = 1, b = 2, c = 3, d = 4, etc.

After getting through that article, I watched a video title If Statements:

“If” statements (also known as “conditionals”) are where you use Booleans to execute code IF the Boolean is True. (Also, in Python True and False both need to be capitalized.) If the Boolean’s False, the computer skips the indented code and executes the next line of code NOT indented. This means that, in Python (unlike other languages), you MUST indent your code when using if statements. The third screenshot above shows how Kim (who’s the instructor for this course) uses an if statement to ask the user for the type of protein they want IF they input “pad thai”. If they didn’t ask for pad thai, because the protein variable is declared as “no protein” BEFORE the if statement, the console will print “with ‘no protein’.” 

I then did an exercise which helped me learn about conditionals:

Unit 2 – Lesson 1 – Exercise 1

Question 1

Question 2

These questions were pretty straightforward on how to use Boolean expressions in if statements. I did have to read the first question above two or three times to figure out what it wanted me to do though… As easy as these questions ended up being, they were still helpful for me to get a better grasp on how conditionals work.

I started the challenge from Lesson 1 on Wednesday morning:

Unit 2 – Lesson 1 – Challenge

This challenge took me about 10 minutes to get through. I initially had to quickly look up how to format the if statement properly. Then, for the first step of setting waste_type to recycling if material = “plastic”, I sort of just guessed at how to format it. Then, for the second conditional, switching it BACK to “trash” if length < 7.5, it became much easier for me to do/figure out. Overall, this challenge was easy but definitely helpful practice.

Also, at the end of the challenge, it suggested looking up local recycling rules to come up with my own conditionals. I asked CGPT for some ideas which I played around with, and then asked Gemini to help me by taking screenshots of my code and asking Gem what I was doing wrong when I got stuck and how I could improve my code. In the end, I was left with this:

I realized that using CGPT and Gemini in this way was SUPER helpful and continued doing it throughout the week. (And I’m assuming will continue doing it going forward.)

The next thing I made notes on was the following exercise I worked through:

Unit 2 – Lesson 2 – Exercise 1

Question 3

Question 4

I got all four of the questions from this exercise correct on my first attempt and found them all pretty easy, although I did have to read each question a few times to make sure I understood them correctly. Like everything from this week, even though it was easy, it was still useful practice!

On Thursday morning I started the challenge from this lesson:

Unit 2 – Lesson 2 – Challenge

This challenge took me about 15 minutes to complete. Getting through step 2 (the third screenshot above) took me a while because I didn’t realize I needed to add parenthesis around (month = 4 or month …). After step 2, I asked Gemini if there was a more succinct way to write the condition and it said to use month in (4, 6, 9, 11) which you can see that I did in the fourth screenshot above. I spent around 30 minutes after I completed the challenge using Gemini to come up with efficient code to check for leap years. The conditional at the end, if(is_leap and day > 29) or (not is_leap and day > 28), was confusing to me at first but made sense eventually and seems like an efficient way to write the program.

The next thing I did was watch the first video from the third lesson titled if-elif-else:

As you’d guess from the title, this video talked about if-elif-else conditionals. Gemini actually had me using them a bit in the previous challenge, but this video really helped make it clear how they connect to each other and how the computer executes the code from top to bottom until it reaches a line of code that is True, then exits the conditional entirely. One helpful thing Kim said was, “To make the separate if-elif-else chains easier to see, programmers often put a space between [these] conditionals. The blank lines makes the program more readbale.” Basically, she was suggesting that when I write i-e-e conditionals back to back, I should put an empty line between each conditional.

On Friday I did the exercise from the Lesson 3:

Unit 2 – Lesson 3 – Exercise 1

Question 5

Question 6

The questions in this exercise were pretty easy/obvious. As you can see, you just had to read through the i-e-e conditionals and figure out what the output would be. It was simple but still helpful! After that, the next thing I made notes on was from the challenge from this Lesson:

Unit 2 – Lesson 3 – Challenge

I was pretty happy with myself that I managed to get through each step of this challenge on my own without having to look anything up. Step 3 of adding a score variable (shown in the fourth screenshot above) was a bit tricky but I eventually figured it out. After finishing the challenge, I asked Gemini if there was a better way for me to write the code and it said to use score += 1 after each question the user got correct and to print the final score using what’s called an f-string which lead to the syntax print(f”Your score is: {score}.” (shown in the fifth screenshot above).

Here’s a few questions I worked through from the exercise in the fourth Lesson:

Unit 2 – Lesson 4 – Exercise 1

Question 7

Question 8

This exercise helped me practice using nested conditionals which is when you “nest” an if statement inside another by indenting it with a tab. When doing this, the nested conditional will ONLY execute if the outer conditional evaluates to True. This was the first exercise I’ve done in CS so far where I got a question wrong. 😔 I forgot to take screenshots of the question I got wrong, but it was the exact same type of question as Question 8 from above. I got it wrong thinking that the 2nd and 3rd options were reversed — that if nested conditionals were true, only the 1st indented conditional would be executed, not both.

Finally, the last thing I got through this week was the challenge from Lesson 4:

Unit 2 – Lesson 4 – Challenge

I didn’t get much of a chance to use Gemini to see how I could improve my code throughout this challenge, so everything you see in the final screenshot was what I came up with on my own. I was pretty happy that I was able to figure out how to execute all the instructions! But, like I was saying earlier, I wish KA would TELL me what I was doing wrong or could be doing better. I think it would be helpful if at the end of the challenges/projects they showed an image of how THEY would write the code so that I could compare mine to theirs.

And that was “it” for this week, although I actually think “it” was quite a lot! I’m really enjoying CS so far but am a bit concerned that it’s soon going to get much more difficult than it has been up to this point. When I think back on going through the Math section of KA, the first few courses (arithmetic, algebra, geometry) were SUPER easy, and then it got much more challenging. I have to assume the same thing will happen here, but the good thing is that I know how to go about unsticking myself if I get stuck — by jumping on Google/YouTube and watching a handful of videos re: whatever I’m stuck on. Unlike with Math, my goal is to get through CS as fast as possible while still actually learning what’s being taught. I’m not exactly sure how fast that will be (Maybe 6 months to a year? Although that would be ambitious.), but I am planning on pushing myself to get it done ASAP. There are a handful of reasons for this which I’m not going to bother getting into right now, but suffice it to say I am FIRED UP to get through this section of KA quickly! 🔥 So, as always, fingers crossed I have a productive week so I can make it happen! 🤞🏼

Leave a Reply

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