The Vine City Code Crew

Session # 0011

Jeremy Harms
6 min readOct 25, 2014

By our third class, session # 0011, it was time to figure out what the heck binary numbers were all about, with all their nebulous 1’s and 0’s… Or as one gentleman asked me before, “what are all those X’s and O’s about anyway that run a computer!?” ☺ He was on the right track, but instead of a big gigantic game of tic-tac-toe, a computer operates a lot more like a billion little light switches all working in unison. Enter: BINARY NUMBERS.

In the video below, motor head James May (of legendary TopGear fame!) explains in a very official and convincing British accent how computers compute numbers that you and I know in our “base ten” system (i.e. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10). Computers calculate those numbers from the only counting system they can understand; known as “base two.” A computer only understands two signals at the lowest level in the machine — an ON electrical impulse and an OFF electrical impulse; just like a light switch. An “on” signal represents to the computer a “1”; an “off” gives it a “0”. It then strings these 1’s and 0’s together and computes the resulting number by doing “base two” math as we’ll see below.

You can watch James in our Prezi deck for a better explanation.

http://prezi.com/eydg5lk_dhth/code-crew-011/

But just in case you didn’t watch him, here’s quickly how it works. ☺ If you remember exponents from math class, “2^3” reads as “2 to the power of 3” or “2 to the exponent 3”. And:

2^3 =
2 x 2 x 2 =
8

A binary number like 1 1 0 1 is interpreted the following way: For any place or position in the binary number where you see a 1, put a 2 in the equation below. If there’s a 0, then just put a 0 there. Put “+” in between each number.

So for 1 1 0 1 we start with this:

2 + 2 + 0 + 2

But we’re not done yet! Gotta get those exponents in there. For the right-most digit, it always gets raised to the power of 0. So the 2 in the far right position becomes 2^0. Then the next digit to the left gets raised to the power of 1. The next to the left is to the power of 2, etc. And on and on… So our equation from above now becomes:

2^3 + 2^2 + 0^1 + 2^0

And in case you don’t remember from exponents, any number raised to the power of zero is equal to 1. So at the end of that equation, that 2^0 = 1.

And now we have:

2^3 + 2^2 + 0^1 + 2^0 =
8 + 4 + 0 + 1 =
13

Therefore, the binary number 1 1 0 1 = 13.

And number 0 0 1 1 = 3. Our third session number! What binary number represents 5? I’ll give you the answer at the end!*

Our coders really impressed me with their ability to quickly calculate the exponents and add up the binary numbers to find the final result. One of our really sharp coders Kamieshia asked, “So binary numbers that end in a zero are always even numbers, and binary numbers that end in a one are always an odd number, right?” Right you are Kamieshia! A very astute observation from a very bright girl…

After our binary math party, during our Python labs we learned all about what a variable does for us in code. Click the pic below to do the labs (exercises 4–7) yourself!

What’s in a Variable?

You can think of a variable in any programming language as a kind of “box” — it let’s us put a value inside of it and carry it around to different parts of our program. Then, when we want to use that variable in our code, we can open our box (i.e. variable) and use the value that we previously stored inside.

You can name variables almost anything you want (no spaces though!). So some example variable names might be:

my_var
YourName
i_like_ice_cream
x

We might put a word value like “Jeremy” inside the variable (in programming a word or a bunch of letter/number characters put together is called a “string,” weird huh?). We can also put numeric values inside variables too — like my age, 34. And then we can do math on that value (I’ll get older next year unfortunately, so a program that computes my_age + 1 should do the trick…) We can even put special kinds of values in a variable called a “boolean,” pronounced “bull-yen”; named for a smart dude back in the day, George Boole.

The Boole dude. Like I said, he was “back in the day”…

A boolean, or bool, only ever has two values: True or False. These words have a special meaning to the computer and it uses them for logical statements for stuff like:

if i_like_ice_cream equals True then:
print "Of course you like ice cream! Who doesn't?"
else if i_like_ice_cream equals False then:
print "What planet are you from?"

So bools function kind of like an on/off switch themselves since a bool only ever has one of those two values.

At the end of the night, I had a very special guest who means a lot to me personally agree to come help out with the Crew and be our tech guest interviewee, Craig Kelly.

Almost exactly a year ago, when I began the job I currently have at a company called EmeraldCube, the idea for the Code Crew began to take shape. When I told Craig and his fellow partners at my company about what it was Drew and I wanted to do with the Code Crew at Redeemer in Vine City, they were totally onboard with the idea and wanted to know how they could help. In addition to my company being a financial sponsor for the Crew, they’ve also been gracious to allow me to donate hours of my work day when needed to prepare for the class. I’ve even been able to block out a month and a half of limited travel to my clients to make sure I could be here in town for seven Wednesday nights in a row. Craig has been a great friend of mine for the past seven years, and I’ve had the good fortune to call him my boss for much of that time as well.

Craig implored and encouraged these coders by giving them the same advice his father, a Navy officer and graduate of the Naval Academy, gave him years before. He urged them to get as much education as they could and to leave their options open for as long as they could by taking various classes and exploring multiple disciplines. Hopefully by doing so, they’d be able to make an informed decision about what it is they find they’re most passionate about and can then focus their energies and efforts there.

Our last Rapid Fire Five question of the night is always: “What’s currently on your on your music playlist?” Craig looked down as he thought, and then smiled his big wide grin as he slowly nodded his head. A longtime fan of the Dungeon Family since his early days as a student at Tech many years ago he responded, “Outkast. Aquemini. Their best album ever.”

Next Code Crew entry: Session # 0100

*Oh, and in case you were wondering… ☺
5 = 0 1 0 1

--

--

Jeremy Harms

Husband, dad, Crimson Tider and The Vine City Code Crew.