MethosH
2009-10-27, 10:33 PM
Welcome to "Learning Basic Programming in the Playground"!
We have seen many threads about "hey, I want to learn how to program" or "I have a question about C" and even "How the heck to I program games? o.O".
And those threads will just keep coming, so why not make something of it?
The idea of this thread is for us, Programmers in the Playgrounds, to write/share some tutorials and basics for the starters, suggest compilers and reply to questions.
Every F.A.Q. and tutorial that end here I'll put on the main post.
I don't have time to write anything specific right now (since it is 1:37 am and I need to be up in 4 hours), but tomorrow I shall start my first tutorial for those that want to learn the basics of programming.
This thread is just starting up, so it will be prettier with time! Trust me :smallbiggrin:
The first step:
First steps: 1 - What is programming and algorithms? (baby steps and the "if then else" statement.
First ask yourself this... Do you know what it means “programming”? Do you know what an algorithm is? What a compiler is? What a programming language is? Before you even start rushing on Java or anything you think grownups use to make those nice games you play you need to understand those things.
If you feel you want to jump right into the action of basic logic you may as well skip this next step. (That is why I’m putting it under spoilers)
The act of programming is using logic and applied math in algorithms to solve problems.
Some may say that you need the knowledge of the technology, but the technology itself is just a tool for the programmer craft, it isn’t the soul of programming.
As Wikipedia would say, algorithms are effective methods for solving problems using a finite sequence of instructions.
Your work as a programmer is to figure out how to solve those problems. Think of algorithms or even use some that are around and are clever solutions. Now let’s talk about the logic behind them.
On every code from now on I’ll use a didactic tool called “pseudo-code”. A pseudo-code is a form of algorithm that does not correspond to any programming language, but is a set of instructions that humans can easily understand.
Now that you understand that an algorithm is a set of instructions you need to know what those instructions are.
Since we are working in a pseudo-code they can be anything you like. Let’s work a sample up so you understand it better.
Say we want the computer to make us a sandwich, first we will tell him what we are trying to do and then tell him what to do. Something like this:
Make me a sandwich:
Get bread.
Get meat.
Get tomato.
Get mustard.
Cut bread.
Get 2 pieces of bread.
Put meat on first piece.
Put tomato above the meat.
Put mustard above the tomato.
Put second piece of bread above mustard.
There you go, we have a very logical sandwich, this is pretty straight forward, but it isn’t very fun. It actually sounds kind of dumb. So let’s make things interesting.
Say we want to do something that forces the computer to make a decision, how will we do that? For example we want the computer to let us know if a given bread is rotten. We know that a bad bread has those nasty green spots. So we let the computer know that.
Is the bread rotten?
Get bread.
Does bread have green nasty spots?
If yes then
Show us it’s not good and throw it away.
Else
Make me a sandwich.
Pretty simple isn’t it? This is the basic “If then else” statement and you will find it in most of computer languages.
Well, that is all for know. I’ll be back later with another topic. Next part: Variables and Loops.
Tutorials:
Python
Python 2.x tutorial (http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python/Intro) (Thanks Fostire)
Python 3.0 tutorial (http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3) (Thanks Fostire)
HTML
Basic HTML by Jokasti
I know TI-Basic, HTML/CSS, and Java, so here's some HTML Basics:
(follow along in Notepad for best results)
HTML is used to make text look better. That is it's fundamental objective.
In HTML, text is in tags. Tags are the < and > signs, and look like this:
<html>
The <html> tag is used to start an HTML document, and </html> closed the document. In most cases, if you open a tag ( <blah> ) then you must close the tag ( </blah> ).
Essentials in a HTML Document: <html> tag, <head> tag, and <body> tag.
Each of these tags needs to be closed. So a basic document is:
<html>
<head>
My Webpage
</head>
<body>
This is my text.
</body>
</html>
That is the format for most HTML documents, but when you get into more serious stuff that changes.
The <title> tag is used to put a title on a page. See up there on the tab where it says "Giant in the Playground..."? That's the title. The <title> tag goes in the <head> and must be closed. So:
<html>
<head>
<title>
My Webpage's Title
</title>
My Webpage's Head
</head>
<body>
This is my text.
</body>
</html>
If you save these with a name, and then add .html to the end, you can open them in your browser.
That's the basics, and I'll add more later.
TI-Basic:
TI-Basic by Jokasti
TI-Basic
--------
For use on a TI-83 calculator and up.
~
To begin, hit that Program Key. Usually it is "PRGM" and near the middle.
You should see three options, "EXEC, EDIT, and NEW".
You can Execute code in EXEC, edit it in EDIT, or create a new program in NEW.
For now, hit NEW, and type in the name of the program.
The first thing you need to learn is the DISP function. It displays text and variables on the screen. To get to it, go to I/O (for Input/Output), and it should be the third option. Hit ENTER, and DISP is now in your program.
It should look like: PRGM:NAME
:DISP
Then hit ALPHA, " " (for a space), and open quote ".
Type any text you want, and end it with another quote ".
Will continue later.
C#:
A small guide for new C# users (http://msdn.microsoft.com/en-us/beginner/bb308756.aspx) (Thanks Rowsen)
Exercises:
General:
A quick exercise by pendell:
Okay guys, Here's a quick exercise:
Reverse a singly-linked list.
That's an elementary question that gets asked a lot during job interviews to separate real programmers from people without IT background who read up on the buzzwords and are faking it on their resume. It's a question any second year CS student should be able to answer. Bonus points if you can do so without allocating new memory.
Respectfully,
Brian P.
Others:
Why not use GOTO?
http://imgs.xkcd.com/comics/goto.png
We have seen many threads about "hey, I want to learn how to program" or "I have a question about C" and even "How the heck to I program games? o.O".
And those threads will just keep coming, so why not make something of it?
The idea of this thread is for us, Programmers in the Playgrounds, to write/share some tutorials and basics for the starters, suggest compilers and reply to questions.
Every F.A.Q. and tutorial that end here I'll put on the main post.
I don't have time to write anything specific right now (since it is 1:37 am and I need to be up in 4 hours), but tomorrow I shall start my first tutorial for those that want to learn the basics of programming.
This thread is just starting up, so it will be prettier with time! Trust me :smallbiggrin:
The first step:
First steps: 1 - What is programming and algorithms? (baby steps and the "if then else" statement.
First ask yourself this... Do you know what it means “programming”? Do you know what an algorithm is? What a compiler is? What a programming language is? Before you even start rushing on Java or anything you think grownups use to make those nice games you play you need to understand those things.
If you feel you want to jump right into the action of basic logic you may as well skip this next step. (That is why I’m putting it under spoilers)
The act of programming is using logic and applied math in algorithms to solve problems.
Some may say that you need the knowledge of the technology, but the technology itself is just a tool for the programmer craft, it isn’t the soul of programming.
As Wikipedia would say, algorithms are effective methods for solving problems using a finite sequence of instructions.
Your work as a programmer is to figure out how to solve those problems. Think of algorithms or even use some that are around and are clever solutions. Now let’s talk about the logic behind them.
On every code from now on I’ll use a didactic tool called “pseudo-code”. A pseudo-code is a form of algorithm that does not correspond to any programming language, but is a set of instructions that humans can easily understand.
Now that you understand that an algorithm is a set of instructions you need to know what those instructions are.
Since we are working in a pseudo-code they can be anything you like. Let’s work a sample up so you understand it better.
Say we want the computer to make us a sandwich, first we will tell him what we are trying to do and then tell him what to do. Something like this:
Make me a sandwich:
Get bread.
Get meat.
Get tomato.
Get mustard.
Cut bread.
Get 2 pieces of bread.
Put meat on first piece.
Put tomato above the meat.
Put mustard above the tomato.
Put second piece of bread above mustard.
There you go, we have a very logical sandwich, this is pretty straight forward, but it isn’t very fun. It actually sounds kind of dumb. So let’s make things interesting.
Say we want to do something that forces the computer to make a decision, how will we do that? For example we want the computer to let us know if a given bread is rotten. We know that a bad bread has those nasty green spots. So we let the computer know that.
Is the bread rotten?
Get bread.
Does bread have green nasty spots?
If yes then
Show us it’s not good and throw it away.
Else
Make me a sandwich.
Pretty simple isn’t it? This is the basic “If then else” statement and you will find it in most of computer languages.
Well, that is all for know. I’ll be back later with another topic. Next part: Variables and Loops.
Tutorials:
Python
Python 2.x tutorial (http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python/Intro) (Thanks Fostire)
Python 3.0 tutorial (http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3) (Thanks Fostire)
HTML
Basic HTML by Jokasti
I know TI-Basic, HTML/CSS, and Java, so here's some HTML Basics:
(follow along in Notepad for best results)
HTML is used to make text look better. That is it's fundamental objective.
In HTML, text is in tags. Tags are the < and > signs, and look like this:
<html>
The <html> tag is used to start an HTML document, and </html> closed the document. In most cases, if you open a tag ( <blah> ) then you must close the tag ( </blah> ).
Essentials in a HTML Document: <html> tag, <head> tag, and <body> tag.
Each of these tags needs to be closed. So a basic document is:
<html>
<head>
My Webpage
</head>
<body>
This is my text.
</body>
</html>
That is the format for most HTML documents, but when you get into more serious stuff that changes.
The <title> tag is used to put a title on a page. See up there on the tab where it says "Giant in the Playground..."? That's the title. The <title> tag goes in the <head> and must be closed. So:
<html>
<head>
<title>
My Webpage's Title
</title>
My Webpage's Head
</head>
<body>
This is my text.
</body>
</html>
If you save these with a name, and then add .html to the end, you can open them in your browser.
That's the basics, and I'll add more later.
TI-Basic:
TI-Basic by Jokasti
TI-Basic
--------
For use on a TI-83 calculator and up.
~
To begin, hit that Program Key. Usually it is "PRGM" and near the middle.
You should see three options, "EXEC, EDIT, and NEW".
You can Execute code in EXEC, edit it in EDIT, or create a new program in NEW.
For now, hit NEW, and type in the name of the program.
The first thing you need to learn is the DISP function. It displays text and variables on the screen. To get to it, go to I/O (for Input/Output), and it should be the third option. Hit ENTER, and DISP is now in your program.
It should look like: PRGM:NAME
:DISP
Then hit ALPHA, " " (for a space), and open quote ".
Type any text you want, and end it with another quote ".
Will continue later.
C#:
A small guide for new C# users (http://msdn.microsoft.com/en-us/beginner/bb308756.aspx) (Thanks Rowsen)
Exercises:
General:
A quick exercise by pendell:
Okay guys, Here's a quick exercise:
Reverse a singly-linked list.
That's an elementary question that gets asked a lot during job interviews to separate real programmers from people without IT background who read up on the buzzwords and are faking it on their resume. It's a question any second year CS student should be able to answer. Bonus points if you can do so without allocating new memory.
Respectfully,
Brian P.
Others:
Why not use GOTO?
http://imgs.xkcd.com/comics/goto.png