Skip to content
ComputerCS
Start learning

Python Programming · Lesson 2.2

The IDE & Your First Program

Meet IDLE, VS Code and the Nerdlyy playground — then write, save and run your first .py file and read your first error message calmly.

01

Learning objectives

  • Name the three parts of an IDE: editor, console/shell and error messages.
  • Save a Python file with the .py extension and run it from an IDE or with python filename.py.
  • Write a program with several print statements and predict its exact output.
  • Distinguish a syntax error from a runtime error in a traceback.
  • Run code in the Nerdlyy playground and read its console.
02

Lesson notes

You could write Python in Notepad, but nobody does. An IDE (Integrated Development Environment) bundles the three tools every programmer touches hundreds of times a day into one window: an editor that colours keywords and keeps your indentation tidy, a console (also called the shell) where output appears and where you can try single lines interactively, and an error reporter that points at the line where something went wrong. IDLE ships with Python itself, VS Code is the most popular free editor in professional use, and this website's playground is an IDE in your browser — same idea, zero installation.

A Python program is a plain text file whose name ends in .py — that extension is the convention every tool uses to recognise it. In IDLE you choose File → New File, write your statements, save as first.py, and press F5 to run. From a terminal the same thing happens with python first.py. What you must never do is name your own file python.py or give it the name of a module you import — the interpreter would end up loading your file instead of the real module, a trap that has confused students for decades.

Pressing Run sets the pipeline from lesson 1.1 in motion: the interpreter starts at line 1 and executes statement after statement, writing each print()'s output to the console in order. When the last line finishes, the program simply ends — there is no special shutdown code to write. If you run the program again, it starts from the top with a completely fresh memory: variables from the previous run do not survive, which is why saving data to a file or database is a separate topic.

Your first traceback — the multi-line error report Python prints — deserves a calm read rather than panic. Read it bottom-up: the last line names the error type (like SyntaxError or NameError) and describes it in English, and the lines above it point to the file and line number. A syntax error is a grammar mistake (a missing quote or bracket) caught before that line can run; a runtime error happens while valid-looking code executes — dividing by zero, or misspelling a variable name. Learning to read the traceback is a superpower most beginners ignore for far too long.

Everything in this course can be practised right here: every lesson page has runnable examples, the Playground is a full IDE with a saveable codebase, and every challenge has its own editor. Use IDLE or VS Code when you want to build larger files and get used to the board-exam environment; use the Nerdlyy tools when you want instant feedback, XP and streaks. The interpreter is the same — only the furniture differs.

03

Worked code examples

first.py — a student ID card program

Five print statements produce five output lines in order. Saving this as first.py and pressing F5 (or running python first.py) writes the card to the console.

print("ICS Part-1 Student Card")
print("-----------------------")
print("Name : Ayesha Khan")
print("Roll : CS-2026-041")
print("Subject: Computer Science")
Output
ICS Part-1 Student Card
-----------------------
Name : Ayesha Khan
Roll : CS-2026-041
Subject: Computer Science

A syntax error — and the fix

The first line opens a quote it never closes, so Python refuses to run. Notice the error is caught before any output — syntax errors stop the whole program. Adding the missing " fixes it.

print("Welcome to Nerdlyy")
print("Let's learn Python")
Output
Welcome to Nerdlyy
Let's learn Python

A runtime error — valid grammar, impossible action

Lines 1-2 run fine. Line 4 is grammatically perfect but mathematically impossible, so a runtime error (ZeroDivisionError) appears when it is reached — and line 5 never executes.

print("Dividing 10 by 2:")
print(10 / 2)
print("Dividing 10 by 0:")
print(10 / 0)
print("This line never runs")
Output
Dividing 10 by 2:
5.0
Dividing 10 by 0:
ZeroDivisionError: division by zero
04

Key terminology

IDE

Integrated Development Environment — an editor, console and error reporting bundled in one tool (IDLE, VS Code, the Nerdlyy playground).

console / shell

The area where a program's output appears and where single lines can be tried interactively.

.py file

A Python source file; the extension every tool uses to recognise Python code.

traceback

The multi-line error report Python prints, naming the error type and the line where it happened.

syntax error

A grammar mistake (missing quote, bracket or colon) that stops the program before the line can run.

05

Common misconceptions

Common mistake

You need to buy special software to write Python.

Correct understanding

Python and IDLE are free, VS Code is free, and the Nerdlyy playground runs in the browser at zero cost.

Common mistake

A program stops at the first blank line.

Correct understanding

Blank lines and spaces around your code are ignored between statements — they exist purely for readability.

Common mistake

Red error text means the computer is broken.

Correct understanding

A traceback is feedback, not failure. Read the last line first: it names the problem and often the fix.

06

Check your understanding

1. Which extension must a Python source file use?

2. print("Result:") is missing its closing quote. What kind of error is this, and when is it detected?

3. In a traceback, which part should you read first?

NERDLYY · FEEDBACK

Help shape Nerdlyy

Your feedback goes directly to the team. We read every submission.

No reply needed — you can send feedback without sharing contact details.