Using IDLE
What is IDLE
IDLE is the interactive development environment (IDE) t hat is used by default with
Python. An IDE is a text editor specifically made for programming. It often comes with other
tools, like a shell, a debugger, and a packager. Don’t worry, though: IDLE is simple and easy
to use.
To open IDLE, go to the folder that Python is in and open the file “pythonw.” Or, simply
search your computer for it and open the first file that shows up.
Using the Shell
The first window you will see is the shell. A shell is a programming interface that allows
code to be input line-by-line. The “>>>” indicates that the user can start entering code that
the shell will run. It will also maintain any data you put in for the lifetime of the shell.
1
For example, the above code created a variable and printed it out. It’s not important that
you understand what this is yet. Just remember that the shell can run code like a normal
program. If you are tasked with doing some simple coding, you can just use the shell.
Try it yourself: type print(“Hello, World!”) into the shell and press enter.
Creating a Program
The shell is useful, but you will want to create entire programs that can be run again and
again. To create a new program, go to the headers and select File -> New File. You can also
do this by pressing [Cmd] + [N] on macOS and [Ctrl] + [N] on Windows.
This will open a blank text editor. This is where you will type the code for your programs.
You can treat this like a regular file. Anything you would normally do, like open, close, save,
save as, etc., can all be done under File. To save the file, you can also press [Cmd] + [S] on
macOS and [Ctrl] + [S] on Windows. The standard file extension for Python programs is .py.
All Python programs will be named “[name].py”. For simplicity, you should save everything
to the folder that Python is in. When working with the robot, you must save programs that
use the robot in the folder that has the robot’s programs inside of it.
Try it yourself: create a new program in IDLE and save it as “Hello [Link].”
Writing a Program
To program, all that you have to do is write text. Of course, this text must be syntactically
and semantically accurate, so it may be hard to read and write. To help you with this
endeavor, many IDEs, including IDLE, allow you to put comments in the code. These are
explanatory lines of text that tell the reader what certain parts of the code does or how it’s
intended to work. To insert a comment, place a “#” before the text you mean to comment.
2
To help you program, IDLE also colors text to indicate its significance. The color codes are
as follows:
● Red: comments
● Orange: keywords
● Blue: definitions
● Green: strings
● Purple: built-in functions
Try it yourself: write the line print(“Hello, World!”) into the IDLE program. As a
comment, write #print(“this will not print!”) on the next line. We will run this
next.
Running a Program
Let’s say you’ve created a program, and you want to run it. To run a program, go to the top
of the editor and select Run -> Run Module. You can also press [F5] on your keyboard. If
your keyboard has a function key (Fn, usually), press [Fn] + [F5].
Try it yourself: run the program you just wrote.