Welcome, gents.
Note: This guide will be using alot, if not only, Python, an open-source coding language, as it is simple and minimalist. Since Python is very easy to read and understand, you probably won't need to know it, but I may or may not decide to teach it later.
=============
INTRODUCTION
=============
Programming is the art of handling data and making it do things, through code. Most people consider a "program" to have to interact with you to actually be a program.
Not true. A program could simply be a line of code that prints a single statement. Programs like this are trivial though - they accomplish nothing.
For example, in Python:
print("Hello, World!")
writes "Hello World" in an output window. This is a program, albeit a very simple one. It does only one thing - collects some data and prints it.
=================
BASIC DATA TYPES
=================
Before I get into data types, I will explain variables.
Variables are the key to programming. You use variables to store data in, and as the name suggests, they are variable.
Observe this line of code:
variable = "x"
I have stored the letter "x" in "variable".
Now, by doing something like this...
print (variable)
We can write out the contents of the variable, in this case, "x".
As you can see, variables are incredibly powerful, and they are what allow you to store and manipulate code. Another example:
a = 3
b = 2
print (a + b)
Writes out "5".
For a note on variables: "A" and "a" are NOT the same variable. They are two different things.
There are two basic data types that can be stored in variables. These are called "strings" and "integers". While there are other, more complex ones, these two are the absolute basic.
A string contains data in the form of text. For example:
string = "A String"
The variable "string" now contains "A String".
Integers are simply numbers.
integer = 9
But what if we did this...?
string = "9"
integer = 9
print (string + integer)
Well, I can tell you right now, it would generate an error. While YOU may see them as the same thing, the computer is just a bunch of circuits, and it sees one as text and one as a number. Keep this in mind - if you want to get user input and do math with it, you'll have to convert it to an integer first
So basically, keep in mind that strings and integers are two different things.
=============================================
WHAT PROGRAMMING LANGUAGE SHOULD I LEARN?
=============================================
There is no real answer to this question. At all.
Everyone you ask will have a different opinion, a different preference.
It all depends on what you want to do.
If you are truly interested in learning programming well, have a shot at C first. It will teach you VERY strict programming concepts, and when you've learnt or experienced the hardest, everything else is easy.
Ruby and Python may also be considerable, due to their simple syntax.
Other than that, it is really up to you. Do your research, and make your own decision.
======================================
CONTROL STRUCTURES IN PROGRAMMING
======================================
"Control Structures" refer to a way to make a program do different things based off of different results. They are IMPERATIVE to make programs work.
If you wish to just learn the theory behind this, just follow along. If you want to actually make the program, go to
www.python.org and download Python 3.1.
The codeI'll just write the code, then explain it bit by bit at the end.
response = input("Enter your response: ")
if response == "yes":
print ("Response was 'Yes'")
elif response = "no":
print ("Response was 'No'")
else:
pass
Explaining.response = input("Enter your response: ")
In Python, "input()" is a way to get user input. You fill the brackets with a string, prompting them. In this case, I have assigned whatever "input()" gets as a variable, "response".
The following block of code containing if, elif and else is what is known as an "if else" structure, the primary control structure in Python and the basic control structure in other languages.
If Else works like this:
If (condition):
(do this)
So, in this case, I've said that if "response" == "yes" (== means is equal too, = is used to assign variables) then to say the response was yes.
The works because if the person types in "yes", then it prints that line of code.
"Elif" is the exact same thing, but its simply used to set a second "if" in the same block. The reason for this is that we could get two "if" blocks executing at the same time if we used two "if"s.
Lastly, the "Else" statement catches anything else that was entered and simply does nothing, with the statement "pass".