Posted by & filed under Uncategorized.

Welcome to Python for Teens, Part 2. In this part, we will learn about variables, types, and if-statements.

This is where programming meets fun. Variables let you keep track of a number, some text, or many other different types. Speaking of which, we learn about many different types of variables.

Let’s start with variables. Fire up your python interpreter and we will start. (If you forget how to do that, look back at Part 1 of the tutorial.)


To set a variable, simply enter:

variable_name = 928

Now change it to:

print variable_name

As you can see, this prints out the number that we set it to: 928. Variables are used to keep track of things that change. For example, if I wrote a game and I wanted to keep track of score, I would use a variable.


Everything in python has a type. When you assigned the variable variable_name, you assigned it to a number. In programming, a number is referred to as an integer.

When you type print "Hello, World!", you are running a command called print on "Hello, World!". The type of the code that is enclosed by quotes (double or single) is called a string. You can remember that a string is a string of letters and numbers.

Remember that “9″ and 9 are two different types. The first one is a string since it is enclosed by quotes, and the second one is an integer since it is just a number without quotes.

Finally, the last type you will learn is a boolean. This is either True or False. Note that a boolean must be capitalized and it must not have quotes (Or else it is a string).

If Statements

If statements run some code only if a conditional is true. A conditional is a statement that returns a boolean. The most common conditional statements are listed below:

Operator Meaning Example
== Is equal to 5 == 5
> Is greater than 6 > 5
< Is less than 4 < 5
<= Is less than or equal to 5 <= 5
>= Is greater than or equal to 5 >= 5
!= Is not equal to “a” != 5

Now, using any of these, you can form an if statement to run a block of code if the conditional is true. We can do this as shown:

if conditional:
    print "RUN BLOCK OF CODE"

Great! Now, let’s do a test using a useful program.

if name=="Julian":
    print "Hello Julian!"

This will check if the name is equal to “Julian”. If it is, then it will print Hello, Julian! Try running the program. As you can see, it prints out “Hello Julian!” In the next tutorial, we will talk about expanding the if statement, and getting some input from the user. Before that, please take the quiz below. If you get anything wrong, reread the part you missed.

Your Score:  

Your Ranking:  

Posted by & filed under Uncategorized.

Python is a computer programming language. You can use it to make productive apps, games, and more. If you are reading this article, you probably have no idea what variables, statements, or even code is. This is an introductory course for teens into the fascinating world of computer programming.

Installing Python

The first step towards becoming a python master. Installing Python. FUN. First of all, note that if you are on a Mac, you already have Python installed. Windows users, download it from here. Double click the installer which should guide you through the necessary steps.

Python Interpreter

This step is called Python Interpreter, right? Well, first off, what is an interpreter? An interpreter is something most computer programming languages have. It takes some code, which you type in line-by-line and runs it. Let’s try it out:


Go to the start menu, all programs, and then find IDLE.


Startup This app is located inside your Utilities folder in your Applications folder. Type in python and press enter.

If you followed the above steps correctly, you should get something looking like the screenshot below.

Like I said, the colors may be a little bit different, but, all-in-all, it should like mostly like this.

First Line of Code

Now you will write your first line of code. Remember to type the code by hand instead of copying and pasting. YAY! Type the following into the interpreter:

print "Hello, World!"
NOTE: Make sure “Hello, World!” is in quotes.

Press enter, and you should get something that says “Hello, World!”. Good job. You have completed the first step into becoming a master programmer.

I know this doesn’t seem like much, but, let’s dissect it and see what the computer figures out.

The first part of the statement is a command. The computer processes this command to figure out what to do. “Print” tells the computer to print out a line of code onto the computer’s screen. The computer then continues on to look at the second part which tells the computer what to print. In this case, the computer prints “Hello, World!”.

The reason you put the “Hello, World!” in quotes is so that the computer knows that it is a string of letters and not a number or some other type like that.

To run the code from a file instead of typing it into the interpreter each time, download Sublime Text 2. This program can be used free forever. Start Sublime Text 2 and type in your program. Next, save it somewhere on your computer with the ending being .py. (Ex. Press ⌘B to start it up and look at the output below.

Posted by & filed under arduino.

In this mini-tutorial, you will learn how to determine the value of resistors.

Types of Resistors

We will go over the first two types listed here.

  • Four Band – Have two value bands, one multiplier band, and one tolerance band.
  • Five Band - Have three value bands, one multiplier band, and one tolerance band.
  • Six Band - Have two value bands, one multiplier band, one tolerance band, and one temperature band.

Resistor Chart

This is a great resource to have.

The top resistor has a first band of 3, a second band of 9, a multiplier of 10kΩ, and a tolerance of ±10%. This would make it a 39kΩ resistor with a tolerance of ±10%.

The bottom resistor has a first band of 3, a second band of 3, a third band of 9, a multiplier of 1, and a tolerance of ±1%. This would make it a 339Ω resistor with a tolerance of ±1%.

Ω is the ohm sign, which is a measurement of resistance.

Posted by & filed under arduino, Tutorial.

Getting Started

In this quick tutorial, I will be teaching you how to make a simple blinking light with the Arduino. This is a very simple starting tutorial if you want to start learning Arduino.

What is Arduino anyway?

Arduino is a simple way to program different electronics to do things. For example, we will program and build a light blinking.

Why should I learn it?

Arduino is a great way to get started in electrical engineering, software engineering or both.

Now, enough talk, let’s get started. Before we begin though, make sure you have the necessary parts.


LED – Light Emitting Diode (light)

Arduino – The Brain (that we program)

Step 1: Build it!

Build the circuit that you see above. It is pretty self-explanatory. Make sure you plug the shorter leg of the LED into ground (denoted by GND)!!! This is the simplest circuit you can make, but, good job. You have just completed your first circuit. Now, to the programming.

Step 2: Programming it!

The programming is a small bit harder. First, you have to download this file and install it: Arduino. Startup the file you just installed and… Excuse me pouring a bunch of code on you, but, here you go:

  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

Let’s go over this code. First, we declare a variable that the computer can go back to and refer to, which, is the pin number that we will be blinking. Next, we initialize that pin for OUTPUT. Note: Inside the brackets after the void setup() is where something happens only once at the beginning and void loop() happens as soon as possible over and over again. Then, we turn the LED on wait a second, turn it off and wait a second and then do it again and again and again.

Plug in your Arduino through USB and hit the right arrow that says upload at the top to upload it to your Arduino. After rapid blinking of the onboard lights, the LED should start blinking. Good Job. You have finished the first tutorial.

Posted by & filed under python.

Here are different books and websites for programming games. You should start off with the beginning programming resources and then continue with the beginning game programming resources. I highly recommend the Think Python series.

Beginning Programming Resources
Think Java
Think Python
Official Python Tutorial
Java Video Tutorials
Python Videos
How to Install Python
Sublime Text 2 (Great Python Editor)
Eclipse (Great Java Editor)

Beginning Game Programming Resources
Python Game Library
Light Weight Java Game Library
Python Game Library Tutorial
Setting up Eclipse with LWJGL
LWJGL Video Tutorials
LWJGL Text Tutorials
Another Pygame Tutorial
Pygame Demo (More on side bar)

Posted by & filed under pygame, python, Tutorial.

In this four-part series, we will be building a small, side-scroller RPG. The first part in the series will make a base class with two main classes Player, and Wall.

Here is how I am laying out the tutorial:

  1. Base Classes
  2. Physics
  3. Map
  4. AI

To start off, create a couple of the base files for the game:


Later we might add more like a spike class. Anyway, let’s start out with If you want, you can just copy and paste the code since we will be going over it later.

All of the base classes are simple. The reason we put them in is so that it is easy to add new features such as attack strength, agility, defense, etc. Also so that we can easily show the player on the screen

The next file,, will be our base class for anything that collides with the player or any entity.

The first couple of lines are pretty much the same, but, with different names, with the exception that instead of saying type, we say type1. This is because python has a built-in function called type and those two would collide and it wouldn’t be pretty.


This line makes it so that later, we can add explosions. Now, you have finished the grunt work of the game. Time to get started on the graphics.

Posted by & filed under pygame, python, Tutorial.

In this part of the tutorial, we will be adding the basic structure of the game in as well as some of the graphics and physics. If you haven’t already read the first part, then you should do that now. Download the graphics here.

Let’s get started. If you run the following piece of code, you should get something like a blank window.

Let’s go over the code:

  1. Initializes the PyGame window
  2. While running is one, poll for new events
  3. If there is an event called pygame.QUIT, the game exits.

Pretty simple right? Now let’s add a couple more lines at the end.

screen.fill((0, 0, 0))

This should fill the screen with a black color. If you adjust the three zeroes, you should be able to change the color. Experiment with this a bit until you have a nice sky color. (HINT: The three numbers stand for red, green, and blue respectively.)

These are the numbers I came up with: (100, 127, 180)

Let’s draw our player on the screen so we can control him. We will use the Player class we setup last time. We have a lot to add so this will be a revision:

You need to make sure all of the files are in one folder. This should show the main character in the middle of the screen waiting to be moved. Let’s add some controls now. First add a controls variable that stores the current state of all the keys.

controls=[False, False, False, False]

All of the False things represent the current state of the keys. You can add this right after all of the imports. Replace all of the event stuff with this:

events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
running = 0

This basically puts all of the events into one variable and then goes through those events. Now we can add the keypress functionality to the event part. I’ve added the keyboard implementation, but, I left out jump, and crouch since that will have to go with gravity. It is pretty self explanatory. If there is a keydown event check what key it is and update the controls variable accordingly. Now you can see why we put the move method in Player. screen.blit(player.image, player.position) puts the player on the screen.

Now, what’s next. We’ve made the window, the controls. We still need the physics and the map. Let’s do the physics. Remember that update method we made in player and the line that says pass. Replace that with this:

This is basically saying increase the vertical speed by 0.5 every frame, and then, increase the Y-position by vertical speed every frame. If the Y-position>400(window height)-64(player height), than stop them from falling and put them back to 400-64. One last thing of this part. Jumping. to jump, all we have to do, is decrease the vspeed to be a negative amount. The final version of both files: