Saturday, December 21, 2024
HomeComputer programmingUse Python 2 with the Python IDLE on Windows

Use Python 2 with the Python IDLE on Windows

The beginning Python user needs to know how to install Python on a Windows machine and how to get started using IDLE, the Python IDE.


Python is a fun and powerful language. With it, you can see instant results. The Python syntax is easy to visualize and allows for headache-free programming. This tutorial describes how to download Python 2 and start programming in its shell and compiler.

1 Head on over to http://www.python.org/, and select DOWNLOAD on the left-hand side of the website. On the download page, look for Python 2.7.3 Windows Installer (Windows Binary — does not include source). Notice the emphasis on Python 2. That is correct. We are not using Python 3. There is much debate on whether Python 2 or 3 is better. At the end of the day, this is up to you. I personally prefer Python 2.

Download Python 2.7.3 Windows Installer

Also, keep in mind the exact version might be different. (For instance, 2.7.3 might be 2.7.4 in three months from the posting of this article.)

2 You will get a .msi file. Open it, and install it like you would any other program. It is a straight forward install process.

Installing Python 2

3 Once you have it installed, we need to launch the Python Shell. Go to Start on Windows, and look for the Python folder. Then select IDLE(Python GUI).

Python IDLE

4 Think of the Python IDLE as an IDE. It has a Python Shell in it, which lets us program in real time (similar to Ruby), but it also contains a debugger, static programming (such as notepad++, but simpler) and some other tools. By default, you will see a much prettier Python Shell when you open the IDLE.

Python Shell

5 From the shell we can give commands, and get instant results. Python will evaluate what you have typed, and print the object to the screen. For example, we can type 2+2, and get the answer of 4.

Python Shell 2+2

6 I am not going to go into detail with the Shell, but as you probably imagine now, it is very powerful and great for testing things. You can set variables, run loops, and just about anything from the Shell. Now, let us look at how to type a more structured program. Go to File – New Window at the top of the shell, and a new window will pop up.

Python Window

7 In this Window, we can now write a complete program. Take for instance this quick “program:”

Python hello world

8 To run this, I would click on Run -> Run Module (F5). It will prompt you to save your document as well. Then your Python Shell Window will take the stage, run this code, and display its results in the Shell.

Python Shell Restart

9 Then it is as simple as flipping back and forth and testing. The IDLE makes life easier and programming in Python is a blast.

Chris Luongo
Chris Luongo
Chris is a self-taught web designer and developer out of Atlanta, GA. This geek enjoys coffee, cold brews, bike riding, and twisting any form of tech into submission.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!