Learn Computer Programming  Beginner Tutorial
Why did I choose computer programming?
Computer programming has been one of my passions since I was 11 years old. I'll never forget how excited I was when my parents bought me my first ColecoVision computer! At that time, computers were primarily tape driven. Flipping through the operator's manual, I discovered that my machine was fully programmable! Writing my first program and seeing it in action was a euphoric moment for me! That's all it took to get me hooked!
Why did I write this Hub?
The goal of this Hub is to encapsulate my knowledge, consisting of over 11 years of experience, into an article that propels the reader into the Information Age.
One of the challenges I've experienced is finding a single text that covers how mathematics and computer programming are interrelated. Often these are viewed as disparate topics. My objective is to provide you with a holistic learning opportunity that brings these two worlds together and provide you with a solid foundation into the world of programming.
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." – Socrates
Why should I get into computer programming?
The landscape that we once knew is rapidly changing. We've seen a paradigm shift that has propelled us from the Industrial Age into the Information Age. Our society has become so dependent on technology that it's hard to imagine our world without it.
An exciting innovation that has taken the development world by storm is the advent of software distribution marketplaces. Developers can now upload and sell their applications to the masses. Imagine that you designed a topnotch phone application that becomes popular and decide to sell it for $0.99 cents a download. Note: Keep in mind that the marketplace vendor will charge 20%30% off the top. So roughly $0.30 per sale will go back to the vendor. If the application gets 100,000 downloads, you would bank $70,000 (not including taxes). Electronic distribution has incredible potential as there is nothing to ship! It's like selling air!
Software Requirements
This Hub does not require any software to be installed. In fact, all of your programming will be done online using JavaScript! Once all of the math concepts have been mastered, you'll be on an excellent path to becoming a great programmer!
Math Essentials
Some basic math and Algebra will go a long way in your programming career. Many of the concepts in math will translate directly over to computer programming. I see math as a collection of tools that can be used to solve a problem. In my opinion, learning how to apply math to a real world problem is more important than the mechanical steps needed to solve.
Important: At this point in the tutorial, don't worry if some of the math concepts seem foreign. For now, I just want you to become familiar with them. Later in the tutorial, you'll see how these concepts come together.
Math  Variables
A variable is simply a container. Think of it as like an empty box that can hold something.
In Algebra, you may recall a simple statement such as:
x = 10
In this example, the number 10 is assigned to the variable x. So variable x now equals 10.
Let's look at another problem.
10 + x = 14
In this simple problem, we can easily infer that x must be equal to 4 to balance the equation.
Math  Variables  Quiz
view quiz statisticsMath  Comparison Symbols
In Math, we can use symbols to compare numbers and variables. These symbols are:
< (Less Than)
≤ (Less Than Or Equal To)
> (Greater Than)
≥ (Greater Than or Equal To)
= (Equals)
≠ (Not Equal)
Math  Comparison Symbols  Quiz
view quiz statisticsMath  Order of Operations
In math, the way in which terms are ordered can dramatically the impact resulting calculation. For example:
2 + 3 × 5
Intuitively, it's easy to assume that the first set of terms (2+3) would be calculated first. This is wrong however, as it would yield 25 which is incorrect. The correct answer is 17. Why? You may recall the mnemonic PEMDAS. This is the order in which terms should be evaluated.
P = Parentheses
E = Exponents
M = Multiplication
D = Division
A = Addition
S = Subtraction
Don't let the mnemonic fool you however, the M and D does not explicitly mean that multiplication happens before division. The same applies to A,S.
How can we ensure that the calculation for 2+3 happens first? We do this by using parentheses. For example:
(2 + 3) x 5 = 25
For more information, check out this tutorial: Operations in the correct order
Order of Operations  Quiz
Let's go ahead and do a practice quiz:
Problem:
2 + (3 × 5)
Answer: 17  The terms in parenthesis are calculated first.
Problem:
2 + 3(5)
Answer: 17  The multiplication terms are calculated first.
Problem:
2 + 15 ÷ 5
Answer: 5  The division terms are calculated first.
Problem
5  2 + 2^{2} + 15 ÷ 5
Answer:
 Exponents always come first so let's simplify 2^{2}5  2 + 4 + 15 ÷ 5
 Division comes before addition/subtraction so let's simplify further
5  2 + 4 + 3  Now read from left to right
3 + 4 + 3  The final calculation is
10
Problem
5 x 5 ÷ 5
Answer: 5  When adjacent multiplication/division terms are present, solve from left to right.
Problem
24 ÷ 6 x 5
Answer: 20  The same rule applies, when adjacent division/multiplication terms are present, solve from left to right.
Problem
5  2 + 5
Answer: 8  When adjacent subtraction/addition terms are present, solve from left to right.
Problem
4 + 3  4 = 3
Answer: 3  The same rules apply, when adjacent addition/subtraction terms are present, solve from left to right
Working with Positive and Negative Numbers
Working with positive and negative numbers is an essential skill you will utilize throughout your programming career.
My wife and I were joking around one morning as I posed the question, "Do you love to hate me or love to love me." Right then, it dawned on me that this was the perfect example for illustrating the Algebra rules surrounding positive and negative numbers. Think of the positive as "love" and the negative "hate". Let's look at each of these statements and determine if it's positive or negative (Note: the positive and negative signs are added for reference):
1) I love (+) to hate () you.
Answer: negative statement
2) I hate () to love (+) you.
Answer: negative statement
3) I love (+) to love (+) you.
Answer: positive statement
4) I hate () to hate () you.
Answer: positive statement
Now let's apply what we have just learned. To get started, read through the following tutorials to get a basic understanding of how to add, subtract, multiple, and divide positive and negative numbers:
AND vs. OR Operators
A condition is a statement that yields either a true or false answer. As an example, imagine that you are a customer attempting to sign into an internet web site that requires security credentials to be entered. In order to be authenticated, certain conditions must be met. Let's have variables A, B and C represent each of the following conditions:
Let variable A = Customer entered correct password (True/False)
Let variable B = Customer entered correct security question # 1 (True/False)
Let variable C = Customer entered correct security question # 2 (True/False)
The "And" Operator
Joining these three conditions using the "AND" operator will require that A and B and C be correct. Of course, this will make logging in more difficult. In plain English, we would say, "If both the password (A) is correct and security question # 1 is correct (B) and security question #2 (C) is correct, then allow the user to login.
The mathematical notation would look like this:
a ^ b ^ c
The caret (^) symbol is used to represent AND which is a conjunction.
The "Or" Operator
Note: For security purposes, condition A should always be true.
Now let's us imagine that we are the system administrator who sets up the security rules for the website. What if we wanted to require that only one security question be correct? This is where we would use the "OR" operator. To join these conditions we would require that A be always true and either B or C be true. In English, we would say, "If the password (A) is correct and either security question # 1 (B) or security question #2 is correct, then allow the user to sign in.
The mathematical notation for this scenario would be:
a ^ (b v c)
The (v) symbol is used to represent OR which is a disjunction.
And vs. Or Operators  Quiz
Use these variables to answer the following questions:
Let a = True
Let b = False
Let c = True
Answer True/False
Problem
(a v b)
Answer: True. Only one of the two variables has to be true.
Problem
(a v b v c)
Answer: True. Only one of the three variables have to be true.
Problem
(a ^ b)
Answer: False. Both variables would have to be either true or false.
Problem
(a ^ b ^ c)
Answer: False. All 3 variables would have to be either true or false.
Problem
(a ^ c)
Answer: True. Both variables are both true.
Exploring the Truth Table
Now that we understand the math notation, we can now summary the possible outcomes using a truth table.
a
 b
 a ^ b
 a v b


True
 True
 True
 True

True
 False
 False
 True

False
 True
 False
 True

False
 False
 False
 False

Negation
An easy way to think of negation is to think in terms of opposite value. In plain English, it's like saying the word NOT.
The mathematical notation uses the tilde (~) symbol in front the variable to represent NOT. This truth table demonstrates negation.
a
 ~a


True
 False

False
 True

Sets
A set is simply a collection of things. So to visualize, we can think of a collection as a big box that can contain many values.
In the mathematical world of Set Theory, the syntax for a set looks as follows:
a = {1, 2, 3, 4, 5}
From this example we can see that variable A holds a list of numbers.
Math  Intersects
With intersects, only numbers existing in both sets become part of the merge. Here are some examples:
Example 1:
A = {1,2,3,4,5}
B = {1,3,7,8,9,10}
A ∩ B = {1,3}
In plain English, it is like saying, "Show me all items that exist in both A and B.
Example 2:
A = {1,2,3,4,5}
B = {7,8,9,10}
A ∩ B = ∅
Math  Unions
How do we combine two or more sets together? Easy, we union them. The math symbol for a union is υ . In programming, you will be working with all kinds of different sets. It's often necessary to bring two sets together.
Let's look at an example:
A = {1,2,3,4,5}
B = {5,6,7,8,9,10}
A υ B = {1,2,3,4,5,6,7,8,9,10}
In plain English, we would say join everything that exists in either A or B.
It's important to note that although both sets include a 5, only one 5 is recorded in the final set.
For more information on Sets and Venn Diagrams, I highly recommend going through the following mathisfun.com tutorial at: http://www.mathsisfun.com/sets/venndiagrams.html
Math  Functions
What is a function? A great analogy I often hear is a function being like a vending machine. With a vending machine, a token goes in and the merchandise comes out. Similarly with a function, a variable (with an assigned a value) goes into the function and a resulting calculation comes out.
The math notation for a function is "f(x)" where "f" is the function name and within parenthesis is the variable:
f(x) = 2 + x + 5
One of the best ways to understand this concept is to see an examples:
Example A
Pass zero into the function
Step 1  Replace variable a with 0
f(0) = 2(0) + 5
Step 2  Simplify
f(0) = 0 + 5
Answer: f(0) = 5
Example B
Pass 5 into the function
Step 1
f(5) = 2(5) + 5
Step 2
f(5) = 10 + 5
Answer: f(5) = 5
Example C
Pass 10 into the function
Step 1
f(10) = 2(10) + 5
Step 2
f(10) = 20 + 5
Answer
f(10) = 25
Let's Start Programming!
In order to write a program, we will first need a programming language. An excellent language for beginners to dive into is called JavaScript. This is a simple, yet powerful, programming language that is extensively used by web developers to build rich interactive websites. Web browsers have their own builtin JavaScript interpreter. Think of this interpreter as a translator that can read our code and translate it into something meaningful that the user can work with.
One of the best tutorials on the web for learning this language is hosted for free by W3Schools. To get started, visit:
http://www.w3schools.com/js/default.asp
As you go through this tutorial you'll begin to understand how the math concepts we learned directly relate to programming. You now have a tremendous mathematical foundation that can be used to kick start your programming career and put you on the right path!
Note: If your not familiar with the HTML in this tutorial, I highly recommend going through this tutorial first:
http://www.w3schools.com/html/html_basic.asp
Also check out the tutorials on Code.org:
http://code.org/learn
Other Great Resources on Amazon
What is your favorite programming language?
© 2014 Isaac Ortiz
Comments
Excellent resource, Isaac  I'll certainly take a look at it! Thanks a bunch for taking the time
Wow  this is a heckuva pickmeup lol. Thanks for responding, Isaac Ortiz. I think I will buy a few secondhand textbooks on college mathematics, and go through them sidebyside with html and css to start. Hopefully, within a year or two tops I can move on to Java and the rest. I'll definitely take a look at W3schools and try to spend an hour a day starting very soon. Thanks for responding.
5