Python Basics

Tags PSU

The interface:

IDLE is very similar to normal text editors, but with a few modifications to gear it towards python. When you first open IDLE, you are greeted with an interactive shell, which will directly interpret any python code that is typed into it. It should look something like this:


To create a file, or run a preexisting python script, go to File and either select Open , or New File.
This will open the script editing area of IDLE, if it is a new file, then it should look something like this:


Here you can write all of your python code, and it will have the usual syntax highlighting of other development environments.

Running scripts:

To run a script in IDLE, have the script open in an editor window, then go to Run/Run Module and the script will be ran in the open shell window, or will open a shell window and run the script in that window.

Editor vs shell:

To open a new shell, go to Run/Python Shell, and a shell window will pop up.
The biggest difference between the editor and the shell is that the shell will interpret python code as you type it, whereas the editor allows you to write a full script, save it, and run it as a whole instead of as your write it, you also cannot save a script written in the shell, as it is not truly a script when written there.

Saving:

To save a script in IDLE, you can either go to File/Save or File/Save As, or push Ctrl + S on your keyboard.

Details

Article ID: 3001
Created
Fri 10/2/20 5:20 PM
Modified
Wed 9/13/23 10:01 AM
Applicable Institution(s):
Plymouth State University (PSU)