Nishaglobal Education logo

Install Python and run your first program

Install Python on Windows, macOS or Linux, open the IDLE editor, and write and run a program that prints messages on the screen.

Lesson 1 of 1425 minQuiz: 4 questions

🎯 By the end of this lesson you will be able to:

  • Install Python and check that it works
  • Write a program in the IDLE editor, save it and run it
  • Use print() to show text, and add comments that Python ignores
Outline
  1. What you'll learn and why it matters
  2. Step 1: Install Python
  3. Step 2: Open IDLE, Python's own editor
  4. Step 3: Write and run your first program
  5. Several lines, numbers and comments
  6. Practice
  7. Common mistakes
  8. Recap
  9. Quiz
  10. Mark lesson complete

What you'll learn and why it matters

A program is a list of instructions for a computer. Python is a programming language: a way of writing those instructions that both people and computers can read. Python is used to automate office work, analyse data, build websites and create AI tools, and it is one of the easiest languages to start with.

By the end of this lesson you will have Python on your computer and you will have written and run your first program. Everything else in the course builds on these few steps, so take your time.

Step 1: Install Python

Python is free. You download it from python.org, the official home of Python. The newest version when this lesson was reviewed (November 2026) was Python 3.15. Every example in this course was run with Python 3.12 and works with any version from 3.10 onwards, so do not worry if your number is different.

  1. Open python.org/downloads in your web browser.
  2. Windows: click Download Python install manager, open the file and follow the steps. The install manager is the method python.org now recommends; it sets up the python and py commands for you. (The older “standalone installer” still exists but is being phased out. If you use it, tick the option that adds Python to PATH.)
  3. macOS: download the macOS installer (a .pkg file), open it and click through the steps.
  4. Linux: Python is usually already installed. Skip to the check below.

Now check that it worked. A terminal is a window where you type commands instead of clicking. On Windows, open the Start menu and search for Terminal or Command Prompt. On macOS, open Terminal from Applications › Utilities. Type the command below and press Enter.

Windows: type this in Terminal or Command Prompt
python --version

Output

Python 3.12.6
macOS and Linux: type this in Terminal
python3 --version

Output

Python 3.12.6

You should see Python followed by a version number. Your number may be different, which is fine as long as it starts with 3 and is 3.10 or higher.

Step 2: Open IDLE, Python's own editor

An editor is a program for writing code, a bit like a notepad made for programmers. Python comes with a simple editor called IDLE. We use IDLE in this course because it is already installed and has a big Run button. Later you may move to a bigger editor such as Visual Studio Code, which is also free.

  • Windows: open the Start menu, type IDLE and open “IDLE (Python 3.x)”.
  • macOS: open Applications › Python 3.x › IDLE.
  • Linux: type idle3 in a terminal. If it is missing, install it with your package manager (on Ubuntu: sudo apt install idle3).

IDLE first opens the shell window. It shows >>>, which is Python waiting for you to type one instruction. Try typing 2 + 3 and pressing Enter. Python answers 5. The shell is perfect for quick experiments, but it forgets everything when you close it.

To write a program you can keep, you use a file. In IDLE choose File › New File. A blank editor window opens.

Step 3: Write and run your first program

Type this line into the new file exactly as shown, including the brackets and quotation marks:

hello.py
print("Hello, world!")

Output

Hello, world!
  1. Save the file: File › Save. Make a folder called python-course somewhere easy to find, such as Documents, and name the file hello.py. The .py ending tells your computer it is a Python file.
  2. Run it: choose Run › Run Module, or press F5.
  3. Look at the shell window. It shows Hello, world!.
hello.py1 print("Hello, world!")2 print("My name is Asha.")3 print(7 + 5)Python runs line 1, then 2, then 3Output in the shellHello, world!My name is Asha.12
You write instructions in a .py file. Python reads them from top to bottom, one line at a time, and shows any output in the shell.

Let us look at that line piece by piece:

PartWhat it means
printThe name of a built-in instruction (a function) that shows something on the screen.
( )Brackets hold what you give to the function. Every print needs an opening and a closing bracket.
"Hello, world!"Text in quotation marks is called a string. Python shows it exactly as written, without the quotation marks.

Several lines, numbers and comments

A program can have many lines. Python runs them in order, from the top down. Change hello.py to this and run it again:

Python
# My first program: a short welcome message
print("Hello, world!")
print("My name is Asha.")
print("I am learning Python.")
print(7 + 5)

Output

Hello, world!
My name is Asha.
I am learning Python.
12
  • The first line starts with #. That makes it a comment: a note for people reading the code. Python ignores it completely. Use comments to explain why your code does something.
  • The last line prints 7 + 5 without quotation marks. Without quotes, Python treats it as a calculation and prints the answer, 12. With quotes, print("7 + 5") would print the text 7 + 5.

Practice

Guided exercise

Introduce yourself

Write a program called about_me.py that prints three lines: your name, your city, and one thing you want to build with Python.

  1. In IDLE, choose File › New File.
  2. Write three print() lines, each with a string in quotation marks.
  3. Add a comment at the top saying what the program does.
  4. Save as about_me.py in your python-course folder and press F5.
Show the solution
Solution
# Prints a short introduction about me
print("My name is Ravi.")
print("I live in Pune.")
print("I want to build a tool that tracks my expenses.")

Output

My name is Ravi.
I live in Pune.
I want to build a tool that tracks my expenses.

How to get there: Each print() shows one line, in the order they appear. Your own names and words will be different; what matters is that each line has print, brackets, and text inside matching quotation marks.

Your turn

A tiny calculator

Write a program that prints the text Minutes in a day: and then, on the next line, the answer to 24 * 60 (the * symbol means multiply).

Show a hint

One line needs quotation marks and one does not.

Show the solution
Solution
print("Minutes in a day:")
print(24 * 60)

Output

Minutes in a day:
1440

How to get there: The first line is text, so it goes in quotes. The second is a calculation, so it has no quotes and Python prints the result, 1440.

Common mistakes

Everyone makes these when they start. When Python cannot understand a line, it stops and shows an error message. The last line of the message names the problem.

Capital letter by mistake
Print("Hello")

Python stops with this error

NameError: name 'Print' is not defined. Did you mean: 'print'?

Writing Print with a capital P

You see: NameError: name 'Print' is not defined

Fix: Python is case-sensitive: print and Print are different names. Use lowercase print.

Forgetting a quotation mark

You see: SyntaxError: unterminated string literal

Fix: Every string needs a quote at the start and the end, and both must be the same kind (" or ').

Forgetting the closing bracket

You see: SyntaxError: '(' was never closed

Fix: Count your brackets: each ( needs a matching ).

Typing python hello.py inside the >>> shell

You see: SyntaxError: invalid syntax

Fix: That command belongs in a terminal, not the Python shell. In IDLE, just press F5 to run your file.

Recap

  • Python is a free programming language. You installed it from python.org and checked it with python --version.
  • IDLE's shell runs one instruction at a time; a .py file keeps a whole program that you run with F5.
  • print() shows text in quotes exactly as written, and shows the answer to calculations without quotes.
  • Python runs your file from top to bottom. Lines starting with # are comments that Python ignores.

Key terms

Program
A list of instructions for a computer to follow.
String
A piece of text inside quotation marks, such as "Hello".
Function
A named instruction that does a job, such as print(), which shows things on the screen.
Comment
A note in your code starting with #. Python ignores it.

Check your understanding

Answer all 4 questions, then check your answers to see an explanation for each one.

  1. 1. What does `print("3 + 4")` show?

  2. 2. In what order does Python run the lines of a file?

  3. 3. What happens to a line that starts with `#`?

  4. 4. You run `Print("Hi")` and see `NameError: name 'Print' is not defined`. What is the fix?

Answer all 4 questions to check.

Read more

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.