Tutorial Details
- Program: Python
- Difficulty: Easy
- Estimated Completion Time: 20 minutes
Welcome to Python from Scratch, where I’m going to teach you the ins and outs of Python development… from scratch.
In this first lesson, we’re going to choose a version, install Python, and then create the obligatory “Hello world” script. If you’re already familiar with Python, feel free to skip ahead to a later lesson in the series.
Video Tutorial
Companion Article
Choosing a Version
“It’s important to choose the right version.”
There are two versions of Python that are currently being developed: 2.x and 3.x. It’s important to make the right choice ,because there are several differences between the two. Once you’ve learned one, it can be a bit annoying to have to transition to the other. In this series, we’ll be working through version 2.7.1. You may want to go this route in order to follow along with the videos and articles in this series. That said, most things should work with either version. Version two has much more support from third party libraries, whereas version three has more features, and plenty of bug fixes and refinements.
To make things easier, a lot of features that are being added to version three have also being added to version two, so there’s less need to worry about the differences.
Installing the Interpreter
Once you’ve chosen a version, it’s time to install. Download the version of Python for your OS, and run the installer which will get it set up on your machine. There are three ways you can now use Python:
- Python Shell- lets you run commands line by line.
- IDLE GUI – lets you write more complex scripts, and run them in one go.
- Text Editor – any text editor that runs on you system. You can then save it with a .py extension, and run it from the shell.
For now, launch the shell to test if it works correctly. On Windows, navigate to the directory you installed Python. By default, it should be C:\Python27 Once there, launch python.exe. If you’re on Mac or Linux, launch the Terminal, then type python.
I personally find IDLE to be unpleasant to use; so for most of this series, we’re going to be using a standard code editor. If you would rather use an IDE, there are plenty of good ones:
- PyScripter (Windows)
- Eclipse with the PyDev plugin (Windows)
- Netbeans for Python (Windows, Mac, Linux, Solaris)
-
Visual Studio with
Python Tools (Windows) - Eric IDE, best on Linux, available in Ubuntu Software center
Hello World!
No we’re all set up; let’s write your first bit of Python! Go to the shell, type print "Hello World!", and hit enter. The phrase Hello World! should appear.
And that’s it: it really is as simple as that. You’ve written your first Python program! Now is a good opportunity to highlight one of the differences beween version two and three: they changed print from a statement to a function. Don’t worry too much about what those words mean for now. All you need to know is that, if you chose to use version three, you need to write print("Hello World!") — the only difference is that you don’t use brackets. We’ll learn about the technical reasons behind this in a future lesson.
Conclusion
So in this lesson, we set ourselves up with a fresh Python installation, discussed the best tools to write code, and wrote our first program. If you have any questions, I’m happy to answer them in the comments, and I hope you’ll join me for the rest of this series.



A nice effort but not perfect.
Very helpful for getting started. Thanks!
dude, srsly? this?
i’m not retarded! i little ‘googling’ would’ve been more useful!
Pyscripter rules! and version 3 should be encouraged as Guido mentioned recently.
great tut! thanks giles and nettuts! can’t wait to watch more of this series!
I think <a href=”http://www.aptana.com”>Aptana</a> is a good ide for those who want to work on python framework. It is based on Eclipse.
I think Aptana is a good ide for those who want to work on python framework. It is based on Eclipse. Can be found on http://www.aptana.com.
Love it. I’ll be doing all the tutorials for sure. =)
Hmm… I haven’t watched the video, but the article is quite poor.
This is meant to be a ‘from scratch’ tutorial, but you’ve missed out two key point for those new to Python… — – What is Python?
- What can I do with it?
Even if I take nothing else from this tutorial, learning that TAB autocompletes functions and filenames in terminal has made my night complete!
I see you like minecraft
Do you Know about Ninja-IDE? Currently is THE BEST cross platform Python Specific IDE out there, more info about it at:
http://www.ninja-ide.org/
Cheers :)
P.S. Your Lessons are AWESOME!
great tutorial!
i agree that IDEs are a hassle and more trouble than help. i prefer using vi. :-P
The series does say “Python from Scratch” so rather than come here to crap out dung, just stay quiet or do us all a favour and take a dive from a bridge.
So many critics yet none have ever bothered to take the time to teach others. Just leech off of other peoples generosity and then criticize them for it. How disgusting. Anyway… thanks for sharing this tut!
Nice Tutorials It’s Too useful