N3/N4  ·  SDD  ·  Before you start

Setting up Python and IDLE

National 3 & National 4 Computing Science Python 3 · IDLE · Windows 11 Do this once before SDD1 Approx 10 min
Before you start — check both
  • Python 3 is installed on this computer — your teacher has set this up. IDLE (Python's built-in editor) comes packaged with it automatically, so you don't install anything separately.
  • You have your H drive (network storage) available — this is where you'll save your Python files so they're there next lesson, the same as your other schoolwork.

Setup steps

1

Open IDLE

IDLE is the program you'll use to write and run Python code throughout the SDD strand.

  • a

    Click the Start button and search for IDLE, then click it to open. (It may be listed as "IDLE (Python 3.x)".)

  • b

    A window opens with a coloured prompt >>> — this is the Python Shell. It runs code one line at a time as you type it. You will not write your programs directly in here — see Step 2.

2

Open a new file — the Editor window

Your actual programs are written in a separate Editor window, not the Shell. Keeping these two windows straight is the single most common source of confusion when starting Python — the mockup below shows the difference.

  • a

    In the Shell window's menu, click File › New File (or press Ctrl + N).

  • b

    A second, blank window opens with no >>> prompt. This is your Editor — this is where you type your program.

File New File
Editor — untitled.py
print("Hello, World!")
Python 3.x Shell
>>> (output from your Editor program appears here — see Step 4)
Two windows, two jobs: the Editor is where you write your program. The Shell is where the output appears when you run it. Typing your program directly into the Shell will not save it.
3

Save your file before running it

IDLE requires your file to be saved before it will run properly. Save to your H drive so your work is there next lesson.

  • a

    With the Editor window active, click File › Save As (or press Ctrl + Shift + S).

  • b

    Navigate to your H drive. Create (or open) a folder called Computing to keep your files organised.

  • c

    Name the file sdd0_test.py — the .py ending must stay exactly as it is. Click Save.

The file name must end in .py. If you change or remove this ending, IDLE won't recognise it as a Python program.
4

Write and run your first program

Now write one line of code in the Editor window and run it.

  • a

    In the Editor window, type exactly:

print("Hello, World!")
  • b

    Press F5, or click Run › Run Module from the Editor's menu.

Run Run Module
  • c

    IDLE will ask you to save again if you've made changes since Step 3 — click Yes.

  • d

    Switch to look at the Shell window (not the Editor). You should see:

Python 3.x Shell
Hello, World!
>>>
You're all set! If Hello, World! appeared in the Shell, your setup works. Your file is saved on your H drive and will be there next lesson — you can open it again with File › Open from IDLE.

Troubleshooting

✗  I can't find IDLE in the Start menu
Try searching just "IDLE", or look under a folder called "Python 3.x" in the Start menu's app list. If it truly isn't there, let your teacher know — Python may not be installed on this machine yet.
✗  Nothing happens when I press F5
Make sure the Editor window is the one focused (clicked on), not the Shell — F5 only runs code from the Editor window.
✗  I typed my code straight into the Shell and now it's gone
Code typed directly after the >>> prompt in the Shell runs immediately but is not saved anywhere. Always write your program in the Editor window (Step 2) so you can save and reopen it.
✗  I get a red SyntaxError message in the Shell
Check your quotation marks and brackets match exactly what's shown in Step 4 — print("Hello, World!") needs matching double quotes and both brackets. A single missing character is the most common cause.
✗  My file won't save to my H drive
Check that your network drive is connected — it should appear as a drive letter (often H:) in the Save As window's left-hand list. If it's missing, ask your teacher to check your login.
✗  IDLE asks "Source Must Be Saved" and won't run
This means the file has unsaved changes. Click OK on the dialog, which will prompt a normal Save — then it will run automatically.