Programming Vocab

by Mirabelle Jones

Here’s a cheat sheet for some of the vocabulary we’ll be using to talk about algorithms. You don’t need to know these things to understand the general concept of how the algorithm works, but if you’re interested in how they work programmatically, it will help to know these.

Pseudocode: code that doesn’t really work, but reveals the logic of the program as well as all the steps, elements, etc.

Function: a set of instructions grouped together. For example, if we were to write a function to open a door in pseudocode it might look like:

function openDoor(){
	grasp knob;
	turn knob;
	pull door open;
}

Parameters: sometimes our function needs to know certain information in order to work. If I had a function to pick up an item, for example, it might want to know what item I should pick up. This would go between the () of the function and might look like so:

function pickUpItem(item){
	lower hand;
	grab item;
	lift item;
}

pickUpItem(sandwich); 

Variable: a variable is a placeholder for a number, item, element, etc. You can think of it as a way of storing and referring to information. In the above example, item is a variable and can be used to store any item. When we call our function, we’re setting it equal to sandwich on the last line.

Array: an array is collection of elements (numbers) that each have an index. The index allows us to change and manipulate elements in our programs. In the following array, 68 is in index 4. So if we wanted to refer to it, we’d say myArray[4]. It’s index 4 and not 5 because we start counting from 0! 202 is in position zero, so we’d address that as myArray[0].

myArray = [202,2,3,5,68,93]

Increment: this means to increase. When we’re working with sets of information, we usually want to go from one item to the next. This is the same thing as “incrementing.” It is usually written as ++.

i++ is the same thing as i = i + 1

Decrement: this means to decrease. When we’re working with sets of information, we sometimes want to work backwards too. This is the same thing as “decrementing.” It is usually written as –.

i-- is the same thing as i = i - 1

For Loop: we often use loops in programming to avoid having to do the same thing over and over again by writing lots of the same code! In a for loop we set some conditions, then say while those conditions are true, we want to do something. We usually want to do this thing for every item in an array or within a certain range. Here’s an example. Say I want to water every plant in the house and I have 9 plants:

for (plant = 0; plant < 9; plant++){
    waterplant(); 
}

While Loop: while loops are similar to for loops, but they say while some condition is true, do something. We continue to do the thing over and over again until the condition is false, then we exit the loop. If we wanted to count from 0 to 10 we’d use the following loop:

i = 0
while(i<10){
    count aloud i;
    i++;
}

Return: we often end our functions by returning a value or simply just “returning” to break out of the loop.