Hello!
Welcome to this little corner of the internet! Reading long pages with tons of information isn’t fun, and we get that. Here, we’ll do our best to keep this short and simple for you to follow along.
A Friendly Language
The way French, Spanish, and thousands of other languages exist, coding is among one of them. The difference is, we’re talking to computers 🖥
Coding vs. Programming
Coding is writing code to solve computer science problems. This is what you need as a prerequisite to program. Programming is the ultimate goal— programming is the act of using coding to make programs that solve real problems. You need to know the fundamentals of coding to know how to program.
All The Question Marks
Let's get down to business.
Functions - What Are They?
Functions are sets of instructions to carry out specific tasks. They can be reused over and over as many times as needed, making your code much more readable and easier to use.
​
Let's use an abstract idea. For example, we could create a function called makeCookies, which details the steps on how to make cookies. Then, we would call on makeCookies throughout our program wherever and as many times as needed. The neighbors are coming over? Make cookies. We need a snack for school? Make cookies. So, instead of writing the detailed instructions out over and over again, we can write makeCookies in that place and reduce our code.
​
​
​
​
(Here's an example.)
And Variables?
Variables are ways of storing information in a program. The variable is the label on a container which shows us what’s inside. Once a variable has been assigned the name of the variable can be used to bring up the information it stores later on in the program.
If we want to create a game that keeps track of our score, we can create a variable called “score” and set it equal to an initial value of 0 (because how many games start with a score of 10000?).
​
​
(Here's an example.)
Conditionals
These are also known as if-then statements. If a condition applies, THEN follow this command. It's like telling your computer, IF you have sugar, then make some cookies. Of course, it doesn't have to end there. Because what if we don't have sugar? What then? Well, you could stop there—no sugar, no cookies—as sad as it is. Or, there is another option. If-else statements give us more options to converse with computers. IF you have sugar, make some cookies. ELSE, let me know I need to buy sugar. IF you have sugar, make some cookies. ELSE IF you have no sugar but you have everything else, make some cookies anyway (because we love our cookies, sugary or not).
​
​
​
​
​
​
​
​
​
​
(Here's an example.)
Lists
Lists are also known as arrays. These are pretty easy to understand. Lists in coding are similar to the lists we create in our everyday lives. They can be anything, including:
A list of your favorite ice cream flavors:
favIceCream = ["strawberry", "vanilla", "chocolate"];
​
​
​
A list of your favorite cars:
carsList = ["Ferrari", "Toyota", "Honda", "Lightning McQueen", "Lamborghini"];
​
​
A list of your favorite sports:
sportsList = ["basketball", "football", "baseball", "volleyball", "badminton"];
​
​
And the list could go on!
Loops
Loops are what the name suggests, loops! Loops are mainly ways for the program to repeat a task a specific amount of times. Loops allow you to repeat a process over and over without having to write the same (potentially long) instructions each time you want your program to perform a task.
We have two main kinds of loops: for and while.
For loops are loops that run a section of code repeatedly for a specific amount of times till a certain condition has been satisfied. For example, if we want our program to make ten cookies, we could use a for loop instead of writing out makeCookie(); ten times.
​
​
​
​
​
Then we have while loops—while loops are used to repeat a specific block of code an unknown number of times until the condition is met. For example, we can use a while loop to make cookies as well. We can say, while there is still sugar, make cookies, and run the loop. This allows us to continue the loop and as many make cookies as possible till the sugar runs out—this could give us 5, 10, 15, 20, or even more cookies!
​
​
​
Traversals
Traversals are how the computer finds/checks/searches/accesses. Traversing is a process in which each element of a data structure is visited at least once. For example, computers can traverse (search) through items in a list to find what it’s looking for. Remember our list of favorite cars from earlier? If we expanded our list to 300 cars and forget whether or not “Lightening McQueen” is in our list, we can use a traversal to check the list and visit every element to see if what we’re looking for is there.