Programming Class - Introduction
Posted July 28th, 2008 by mattHistory: I’ve offered to teach some high school students that attend the same church as me how to program. I’ve taught programming classes before but this one is unique because it’s happening mostly by email. Therefore I’ve decided to post the classes here. I’m editing them slightly to remove identifiable information about the students and also information about meeting irl. Also, keep in mind that this material is being written on the assumption that the student is a bright, self-motivated learner age 15 - 19 without any prior programming experience.
So lets get started.
I’ve never ever taught a class this way, I’ve only done it in person. I hope it works out well, but if things are tough, lets not hesitate to meet using another way.
First we should talk about communication. Even though we’re meeting via email, I think this class should be interactive and we should keep discussions in the group. There’s a very good chance I’m going to explain things poorly and you’re just not going to get what I’m saying. I’ll apologize in advance and try to avoid this as much as possible.
Here is my plan for the moment:
- Getting started (lesson 0, this email)
- First program
- Basic expressions (make your computer do your algebra homework)
- Types of data
- Using modules
- Conditions/branching (if x = 10 do this, otherwise do that)
- Looping
- Functions
- Making modules
- Write a program that does something
- Classes and object oriented programming
- Write another program that does something
It seems long but some of these topics above are so small we’ll group them together into one lesson. Afterwards we’ll start working through writing a more fun project. We can choose from a couple different options, and if time permits possibly do both of these:
-
Get started with game development - For example, use our newly acquired skillz to create a game where a few shapes fall at random intervals and speeds from the top of the screen down and you have a movable cannon on one side of the screen that shoots at them. This will use object oriented programmings to create sprites (moving objects), use keyboard/mouse input (moving the canon, firing) and collision detection (sprites hitting screen edge, sprites being shot at). Next steps could be introduction of physics, multiple players and possibly network play. I’ve not done a project like this personally so it would be a learning experience for me too, though I have done basic work along this line.
-
Create a web application - use our coding skill to create a web app or two. For example, we could create a mash-up that combines data from facebook and google maps. This will require learning HTML and possibly doing some programming in javascript which is another programming language. I do this type of stuff every day so I’m very comfortable teaching and using it, however it will put more pressure on you to learn some new stuff.
-
Something else… maybe create an electronics project that talks to the computer over USB (requires $$)… an Instant Messenger bot that tries to carry on a human like discussion with people… we can discuss it.
Before we decide, lets start making progress through the bullet points above.
So lesson 0 begins now. I’m going to assume you’re using MS Windows XP. If you’d like to use something else, let me know.
Before we can go to Lesson 1 you need to have the right tools installed on your computer. The programming language we’re going to use is Python. I will not be so bold as to say that it is the best programming language in the world, nor even that becoming a master in Python will get you a high paying job anywhere. As a matter of fact, if I were trying to get you hired somewhere I’d probably have you learn Java. But Python has some benefits:
- It is extremely simple to get started with - write you’re code and BAM that’s it. Other programming languages require other steps (linking, compiling, yuck)
- The code is simple - other programming languages make you learn a bunch of other junk before you can write your first line of code (void main(argc[], argv[]) …)
- It is powerful - modules written by other people allow your programs to do amazing things in one or two simple steps. (c.f. http://xkcd.com/413/ ) - for example, you can write a program to upload your photos to flickr or facebook or send email or do complex mathematical calculations
- It runs on most computers - Apple and Linux computers both have python installed by default, and as you’ll soon see, installing python on Windows is easy. Your python programs will run on any computer that can run python (with some exceptions)
I’d like us all to be using the same version of python. So please download and install these programs in the order listed:
- Python 2.5.2 for Windows Installer
- Pywin 32 add on modules for Windows (there’s a green box near the middle-left part of the page that says “Download pywin32-211.win32-py2.5.exe” click that.
Once you’ve downloaded and installed both of these programs (in the order above) you’ll be able to write your first python program.
Click Start -> Python 2.5 -> PythonWin
This opens the python console. You can type python programming commands and then run immediately. Make sure you see the window, “Interactive Window” with a prompt that looks like this:
>>>
At the prompt type this and press enter:
print "Hello World"
After you press Enter you should see it tell you “hello world”
Congratulations, you’re a programmer now.
Feel free to go to python.org and look at the tutorial (its under documentation). It’s not the best written tutorial I’m sorry to say. You don’t have to read it, I’ll cover everything in the tutorial in later classes.
Bearfruit