Week 350 – May 11th to May 17th

I’m happy to say that my first week studying CS on KA was fairly successful! The first course I’m working through in CS is called Intro to Computer Science – Python, and in the first unit I made it through 11 videos, 8 articles, 3 exercises, and 4 Challenges. (Each unit is made up of sections called “Lessons” which contain vids, exercises, and articles, and at the end of each Lesson there’s a “Challenge”.) I’m guessing I spent ≥ 5 hours on KA, but I also spent at least 5 hours watching CS50 vids and at least 5 hours reading Code: The Hidden Language of Computer Hardware and Software, so all in all, I spent quite a bit of time this week trying to get an initial grasp on what CS is all about. The one thing I’m disappointed about is that I was SO close to finishing off the first unit, Computation Thinking, but fell slightly short. I only had three articles and a “project” left, whatever that is. (I’m sure I’ll get to it next week and can explain in my next post.) But, apart from not quite getting through the first unit, I’m happy with how this week and have enjoyed working through CS so far! 🤓

I spent a good chunk of this week writing out definitions and terminology for things used in Python. Thinking back to studying math, once I learned the English words for the different types of notation (ex. expression, term, operator, etc.), it was much easier for me to understand what Sal was talking about. So, my goal is spend a decent amount of time trying to memorize the specific words used for things in Python code so that, if it’s anything like math, it will be much easier for me to learn quickly. Here are all the different terms/definitions I learned this week:

Integrated Development Environment (IDE)

  • This is the platform that KA uses for students to practice writing code in. I’m assuming that other programs people use to write code in are also called Integrated Development Environment’s. In the CS50 vids, they use one that’s similar but not exactly the same. Below is a screen shot of KA’s IDE. You can see that there are 3 sections/panels to it. The panel on the left is where KA gives you instructions, the centre panel is called the Code Editor where the student writes code, and the panel to the right is the Console where the computer executes and outputs the program the student coded:

Integer

  • The same as in math. Any number that doesn’t have a decimal point, including zero and negative numbers.

Floats

  • Numbers that include a decimal point.

Booleans

  • This is a data type that can only take one of two possible values: True of False (which, in Python, MUST be capitalized.) This is a bit confusing to me, however, because for some reason I always think of an operator like greater-than or less-than. 🤔

String

  • A line of text, but it could also be as simple as a single character. An integer or float could also be considered as a string if it’s defined that way. A string is denoted by placing “quotation” marks around it.

Syntax error

  • This is when you’ve written code that is improper Python code and the computer has no clue wtf you’re talking about. It’d be like if you wrote a sentence like, “hjasbdasd jhjasbcJHB uihidscv”.

Runtime error

  • This is when you’ve written code that technically makes sense, but when the computer tries to run the program, the program doesn’t make sense. It’d be like you saying, “Cook me a foul ball.”

Logic error

  • This is when the code makes sense and the computer executes what you’ve told it to do, but the result is not what you wanted because you’re not very smart and you told it to do something you didn’t actually want it to do. It’d be like if you wanted it to cook you a pizza but you said, “open the garage door.”

Comments

  • When you’re writing code, a comment is denoted with # (i.e. “# [comment]”) which are meant for humans to be able to quickly read and understand what the code below the comment is intended to do.

Variable

  • I’m pretty sure this is just like in math where you often use ‘x’ as a place holder for a value—one that might change.

Assignment Statement

  • This is when you state that a variable equals an integer or a string or something. But, I’m also pretty sure you use the same type of notation (i.e. the ‘=’ sign) to “assign” functions and other things to each other.

Arithmetic Operators

  • These operators are pretty much all the same in Python code as they were in the Math section of KA, except for **, //, and %. The ** means x = ‘an exponent’ (ex. 2**3 = 23), // means divide two numbers and remove the decimal from the quotient, and % means divide two numbers and tell me what the remainder would be.

Type Casting

  • This is what it’s called when you switch a string to an integer. So, for example, if you said x = 3, you’re creating a variable that’s an integer that equals three. But if you then say str(x), the ‘3’ would then be considered a string, so you’d think of it as written in quotation marks, like “3”. This is important because if, for example, you asked a used for their age and they said 36, and you wanted to print their age, you’d have to print it as a string, meaning you’d have to take the integer they gave you, 36, and type cast it as a string by stating str(36) = “36”.

print(x)

  • You use this function to have a string or data value show up in the console (the right side of KA’s IDE).

input(x)

  • You use this function to get a use to give you information. So, from the example in type casting, you’d say, input(“State your age: ”), and in the console, when you ran the program, a line would pop up saying “State your age: ” and the user could say “36”. After that, I believe in your program, the function, input(“State your age: ”) would be equal to the integer 36, but I could be wrong about that.

str(x)

  • This is the type cast function that turns ‘x’ into a string.

int(x)

  • This is the type cast function that turns ‘x’ into an integer.

float(x)

  • This is the type cast function that turns ‘x’ into a float.

bool(x)

  • This is what I’m confused about. You can see the definition I copied from KA in my hand note above, but it’s still a bit confusing to me. Like I said, I’m pretty sure when I learned about Booleans in math, they had something to do with the operators, > and <, and ≤ and ≥, but I could be wrong about. I’m pretty sure this function is going to be important though because I keep hearing “Boolean” in the CS50 vids I’ve been watching.

abs(x)

  • I’m sure that this would turn a negative number into a positive number.

round(x)

  • This rounds a float to an integer.

round(x, y)

  • This one is actually kind of cool. You use it to round a float, ‘x’, to have a specific number of digits after the decimal, ‘y’.

min(x, y)

  • This function and the following function seemed kind of dumb to me as I was writing them out. It seemed to me that if you were putting two values into this function, like min(2, 3), it would be pretty obvious which value was the lesser of the two. But then I did an exercise where I stated that two arithmetic expressions were assigned to two variables and put the variables into the function (this is actually shown in a Challenge at the end of this post) and then the function told me which was the lesser of the two variables. (I’m not explaining this well, but suffice it to say that the challenge I did helped me see the value of this function.)

max(x, y)

  • This does the same thing as the previous function except it outputs the greater of the two values. Also, apparently you can put in a million arguments (which is the word used for the things you put inside the brackets of each function) and it will tell you which of the million values it the greatest.

len(x)

  • This will tell you how many characters are in a given string. So, I’m pretty sure if you said, “len(123456789)” it would show up as ‘9’ in the console.

In one of the articles I read, there was a link to a page that showed all the functions that are built into Python. I glanced through a bunch of them, but there were too many for me to read through. The girl who does the videos (I don’t know her name yet) said that it’s not necessary to remember the notation for each function, but you do need to know that the operations each function can perform exist so that if you have a problem in which a specific function’s operation would be useful, you know about it exists and can then just look up the notation. Anyways, here’s a screenshot of all the functions:

There weren’t nearly as many exercises working through this unit as there generally were throughout Math. 😔 I was a bit sad about that to be honest, but relieved that there were at least SOME exercises. So, here are six questions from three exercises I worked three this week:

Lesson 2: Program Execution – Exercise: Trace Program Execution

Question 1

Question 2

As you can see, the questions in this exercise just had me look at code and choose the answer that would be outputted in the console by the computer. Pretty simple but still helpful as a starting exercise!

Lesson 3: Variables – Exercise: Trace Variables

Question 3

Question 4

These two questions were from the exercise Trace Variables and were both pretty straightforward. They were meant to teach you what you might think of as the Order of Operations of a program, i.e. that the computer will execute the instructions you give it in chronological order from top to bottom. 

Lesson 4: Arithmetic Expressions – Exercise: Evaluate Arithmetic Expressions

Question 5

Question 6

This exercise was pretty easy and just had to do with order of operations for actual arithmetic operations, although it also touched on Ord. of Op. for how the computer executes code.

Finally, as I said in the intro, there are things called “Challenges” which seem to come up at the end of each Lesson. In them, you have to follow some instructions given to you in the IDE. Here’s the challenge from Lesson 4:

Lesson 4: Arithmetic Expressions – Challenge: Coupon Codes

This challenge took me way longer than it should have. In the third screenshot above, I kept putting the closing bracket around the round function in the wrong spot so the I kept getting a runtime error. I kept writing the function as:

  • str(round(min(fixed_discount, percent_discount)), 2)

but, as you can see from the screenshot, should have written it as:

  • str(round(min(fixed_discount, percent_discount), 2))

I initially was getting super frustrated and couldn’t figure out what I was doing wrong, and unlike in the Math exercises, there’s no “get a hint” button so I didn’t know what to. I took a break for a while and when I came back, decided to screenshot the problem and throw it into CGPT who explained what I’d done wrong. I don’t love that I had to “cheat” like this, but I didn’t know what else to do to figure out what I was doing wrong. So, even though I’m not thrilled that I cheated, I’m glad that I at least have a work around to figure out what I’m doing wrong if I get stuck, going forward.

And that was it for this week! Like I said, I’m pretty happy with how things went for Week 1 of CS. I was actually pretty sad at the end of last week when I’d finished Math, so I’m happy now knowing that I still have a subject I can learn and that I can basically keep following the same format I’ve been doing for the past six years. Also, I’m excited that I’m learning more of a “tangible” skill (so to speak) by learning CS. In a certain sense, I feel like CS will be more applicable to the real world. Not to say that learning math isn’t applicable to life in general, but learning how to program could be a useful skill that I could use to create things like, for example, a program for CodaKaizen! But that said, the great thing about having learned math is that 1) the math in CS will be much easier for me now, and 2) I’m not at all intimidated to learn CS considering I went through all of the Math: HS & College section of KA. (I think of having learned math as having “educated” myself, where as learning CS will be like learning a “tangible” skill, if that makes any sense at all.)

To wrap this up—I looked through the eight units in this course and am hoping that I can get through all of them in about 3 months. If I keep getting through the vids, exercises, etc. at the same rate I did this week, I could potentially get through everything in about 2 months, but I’m assuming things will get harder as I go. Either way, as always, fingers crossed I have a productive upcoming week so at the very least it won’t take me 6.5 years to get through all of Computing like it did for Math. 🤞🏼

Leave a Reply

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