Intro to CS Concepts

Computer Science & Programming Vocabulary

Here are some vocabulary words and ideas you might encounter on your journey to learn CS. Computer scientists love vocabulary words. Don't let them deter you, as they're often just fancy names for things you know.

  • algorithm - A series of steps or instructions to solve a specific task (ex: an algorithm to make a peanutbutter and jelly sandwich).

  • coding - Writing code in a specific programming langauge. Often used interchangably with programming.

  • syntax - The specific rules and regulations you must follow when writing code, including things like what symbols and keywords to use and how you must use spacing and capitalization.

  • pseudocode - Writing out an algorithm to solve a problem in a code-like or code-lite format. We often write pseudocode as a first step towards writing a program. You'll often find this on Wikipedia pages or other resoureces.

  • text editor - A program used to edit plain text files, typically used for creating and editing program files. I like Sublime Text for it's simplicity, but other people have stronger opinions and you can listen to them if you want.

  • command line - The text interface to your computer. Instead of the graphical buttons and windows, you can interact with your computer by typing commands into the command line. On Mac, you can get to this via the "Terminal" app. On Windows, open up "PowerShell."

  • IDE (interactive development environment) - An interactive program where you can write and run code, like a combination of a text editor and a command line into one, with some bonus features thrown in. The bonus features can be useful, but also can be distracting.

Beyond that, Google it. Seriously, half of being a computer scientist is strategic Googling. Don't trust everything you read, but do read just about everything.

Programming Core 4

If you learn 4 conepts in computer science, make them these 4. Examples here are provided in pseudocode, so you can focus on the concept and not the syntax.

1. Variables

Variables allow us to store information. They are buckets that we can label and then store stuff in. Later, we can go back to the labeled bucket to retrieve the stuff inside.

For example, let's say I am creating a program that needs to verify someone's age. I might write code like this:

age = 10

That's saying something like I have a bucket called age. Put the value 10 in that bucket. Later, if I want to lookup that number, I could say something like:

print age

That's saying something like print out whatever value is in the age bucket, in this case 10.

Think of them like folders in filing cabinet. If you are the type of person who has a filing cabinet, you probably also have clients. When you get a new client, you add a new folder to your filing cabinet with their name on it. If you want to access the information about one of your clients, you'd find the folder labeled with their name and then retrieve the information about it from them.

Variables can different types. Variables can store strings of text, like a variable called name that stores "Ashley Hansberry" or they can store numbers, like the age variable above. There are even variables that store collections of different values or lists of values, but once you get these basics, those follow later on.

2. Conditionals

Conditionals allow us to make a program that can react to different situations. Conditionals are a control structure that allows us to only do some code if some condition is met, and luckily, they match up with English words pretty well.

For example, let's say I want to allow someone to access my website only if they are at least 13 years old. The situation is something like, if this persons age is at least 13, then allow them to access the site. If not, deny them access. I might write code like this:

if age >= 13 then

print "welcome to the website!"

else

print "sorry, access denied!"

There are many variations on this idea, but the structure always relies on some condition, which we call a boolean expression, to determine what the code does. Boolean expressions might be as simple as age >= 13 or they might be much more complicated, but they always result in a yes/no or true/false answer.

3. Loops

Loops allow us to repeat the same type of task repeatedly, without having to repeat ourselves over and over again. Humans are good at thinking. Computers are good at repetitive tasks. Loops are a control structure that allow us to repeat some action multiple times, based on some pattern or rule.

For example, let's say I want to have my code print "Happy Birthday" once for each year you've been alive. On the one hand, I could ask you how old you are and then write that many print statements. On the other, I could use some type of loop like this:

repeat age

print "Happy Birthday"

Now, loops don't typically use the word repeat. Instead they count up how many times they've done something, much like you might count the number of times you've said happy birthday on your fingers. It might look something like this, which would print happy birthday along with the current count age times over:

for each num from 1 to age

print "Happy Birthday" + num

Most programming languages have different types of loops, commonly for loops and while loops, but they all follow this basic idea. Loops allow us to repeat a portion of code a specified number of times until some condition is met.

4. Functions

Functions allow us to group some related portion of code together under some name so that we may use it multiple times. Functions are also called subroutines, becuase they are kind of like small programs, in that you give them some inputs and then they produce some output. You might have many functions in a program that all work together to complete some task. Each function completes one subtask, so when put together, they accomplish the whole thing.

For example, let's say that in my program I frequently need to check whether or not an age meets some minimum, like in the conditionals above. Instead of rewriting those conditionals each time, I could group them together in a function that told me whether or not they met the age limit. If I wanted my function to print out the results, I might write code like this:

function isOver13(age):

if age>= 13 then

return "yes"

else

return "no"

Then, any time I wanted to know whether someone's age met the criteria, I could just use my function, like this:

isOver13(20)

which would return or report "yes". While the exact syntax and usage of functions varies from language to language, this idea that a function groups together a portion of code for a small task and then reports the answer to that small task remains consistent.

Terminal & the Command Line

If you're working on programming long, you'll probably need to work in a Terminal pretty soon. When you see people doing things that look like "hacking" or something, it's probably just a Terminal window. Here's a brief tutorial focused on navigating in the Terminal and running Python files there, but it applies generally.

CommandLineIntro