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:
Windows:
Go to the start menu, all programs, and then find IDLE.
Mac:
Startup Terminal.app. 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!" |
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. example.py) Press ⌘B to start it up and look at the output below.



Recent Comments