Reading history

Python Get Started: Install Python, Run Your First Program

7 min read 13 views

Install Python 3 on Windows, macOS or Linux, check the version, try the interactive shell and run your first .py file, step by step with real output.

To write Python you need two things: the Python interpreter and a place to type code. Both are free. This lesson gets you from nothing to a running program in about 15 minutes.

In this lesson you will learn

  • How to check whether Python is already on your computer
  • How to install Python 3 on Windows, macOS and Linux
  • How to try code in the interactive shell
  • How to save a program in a .py file and run it
  • Which code editor to pick as a beginner

Check if Python Is Already Installed

Many computers already have Python. Open a terminal and ask for the version number.

  • Windows: press the Windows key, type cmd, press Enter.
  • macOS: open Terminal from Applications → Utilities.
  • Linux: press Ctrl + Alt + T on most systems.

Then type one of these commands:

python3 --version
python --version     # on Windows, try this one too

If you see something like Python 3.13.1, you are ready and can skip to the interactive shell. If you see an error, or a version starting with 2., install Python 3 as shown next.

How to Install Python 3

On Windows

Python’s official way to install on Windows is now the Python install manager. It installs Python and keeps it up to date for you.

  1. Open the Microsoft Store, search for Python install manager, and click Install. (You can also download the same installer from python.org → Downloads.)
  2. Open a new Command Prompt and type python. The first time, the install manager may ask a few setup questions. Answer Yes to the recommended options, and it downloads the latest Python 3.
  3. Close Command Prompt, open a new one, and run python --version. You should see a version starting with 3.

After this, three commands work in any terminal: python, py and pymanager. If setup ever goes wrong, py install --configure runs the setup check again.

Older tutorials show a “traditional installer” with an “Add python.exe to PATH” tick box. Python.org still offers it for Python 3.14 and 3.15, but stops releasing it from Python 3.16. If you use it, tick that box on the first screen.

On macOS

  1. Download the macOS installer from python.org → Downloads.
  2. Open the .pkg file and follow the steps.
  3. In Terminal, run python3 --version. On a Mac, always type python3, not python.

If you already use Homebrew, brew install python works too.

On Linux

Most Linux systems ship with Python 3. If yours does not, install it with the package manager:

# Ubuntu, Debian, Linux Mint
sudo apt update
sudo apt install python3 python3-pip

# Fedora
sudo dnf install python3

No computer handy?

You can still follow the course. Free online editors such as Programiz, OneCompiler or Google Colab run Python in your browser. You can also install Pydroid 3 on an Android phone. Install Python on a computer as soon as you can, because real projects need files and folders.

Try Python in the Interactive Shell

The interactive shell runs one line at a time and shows the result straight away. It is perfect for quick experiments. Start it by typing python3 (or python on Windows) and pressing Enter. You will see a >>> prompt.

>>> 5 + 3
8
>>> "Dhaka".upper()
'DHAKA'
>>> 100 / 8
12.5
>>> exit()

Notice that the shell prints each result without a print() call. A file does not do that, as you will see next. Type exit() or press Ctrl + Z then Enter (Windows) or Ctrl + D (macOS, Linux) to leave.

Write and Run Your First Python File

Programs you want to keep live in files that end in .py.

  1. Make a folder for this course, for example python-course.
  2. Open a text editor and type the code below.
  3. Save it in that folder as hello.py.
  4. In the terminal, move into the folder with cd python-course.
  5. Run it with python3 hello.py (or python hello.py on Windows).
print("Python is working!")
print(7 * 6)

Output

Python is working!
42

In a file, Python only shows what you ask it to print(). Writing 7 * 6 on its own line would calculate 42 and then throw it away.

Check the Version From Inside a Program

Sometimes a program needs to know which Python is running it. The sys module can tell you.

import sys

print("Major version:", sys.version_info.major)
print("Is this Python 3?", sys.version_info.major == 3)

Output

Major version: 3
Is this Python 3? True

The line import sys loads a built-in module. You will learn about modules later; for now, think of it as opening a toolbox that comes with Python.

A Slightly Longer Program

Here is a program with a list and a loop. Do not worry about every detail yet. Type it out, run it, then change the numbers and run it again. Changing working code is the fastest way to learn.

# A tiny study timer plan
subjects = ["Maths", "Physics", "Python"]
minutes_each = 40

for subject in subjects:
    print(subject, "-", minutes_each, "minutes")

print("Total:", len(subjects) * minutes_each, "minutes")

Output

Maths - 40 minutes
Physics - 40 minutes
Python - 40 minutes
Total: 120 minutes

Which Code Editor Should You Use?

You can write Python in Notepad, but a code editor colours your code, spots mistakes and runs files with one key.

EditorGood forPrice
ThonnyAbsolute beginners. Comes with Python built in and shows variables as your code runs.Free
VS CodeMost learners. Install the official Python extension and you are set for years.Free
PyCharm CommunityBigger projects, with strong code suggestionsFree edition
Jupyter Notebook / Google ColabData analysis and machine learning, where you run code in small cellsFree

Our suggestion: start with Thonny for the first two weeks, then move to VS Code.

Common Setup Problems and Fixes

  1. “python is not recognized” on Windows. Close every terminal window and open a new one; the command only appears in terminals opened after installation. If it still fails, run py install --configure and accept the suggested fixes.
  2. The Microsoft Store page opens when you type python. Windows is telling you Python is not installed yet. Install the Python install manager from that Store page, then open a new terminal.
  3. “No such file or directory”. The terminal is in a different folder from your file. Use cd to move into the right folder, or type the full path.
  4. The file was saved as hello.py.txt. Notepad adds .txt. In the Save dialog, set Save as type to All files.
  5. Typing Python code at the terminal prompt. print("hi") only works inside the Python shell (after >>>) or in a file, not at the normal C:\> or $ prompt.

Practice Exercises

Exercise 1. In the interactive shell, work out how many seconds are in one day.

Show answer
>>> 24 * 60 * 60
86400

Exercise 2. Create a file named about_me.py that prints your name, your class or job, and your favourite food on three lines. Run it from the terminal.

Show answer
print("Nadia")
print("Class 11 student")
print("Kacchi biryani")

Exercise 3. In the study-plan program, add "Chemistry" to the list and change the minutes to 30. What total does it print?

Show answer

Four subjects × 30 minutes = 120 minutes.

Frequently Asked Questions

Should I type python or python3?

On macOS and Linux, use python3. On Windows, use python or py; both work after installing the Python install manager.

Do I need Anaconda?

Not for this course. Anaconda bundles Python with many data-science libraries. It is useful later for machine learning, but plain Python is simpler to start with.

Can I learn Python on a phone?

Yes, for practice. Apps like Pydroid 3 run real Python. For longer programs, a laptop or desktop is much easier.

How much computer power does Python need?

Very little. Any computer from the last ten years with 4 GB of RAM runs Python and VS Code comfortably.

Summary

  • Check for Python with python3 --version or python --version.
  • Install Python 3 from python.org; on Windows, use the Python install manager from the Microsoft Store.
  • The interactive shell (>>>) is for quick tests; .py files are for programs you keep.
  • Run a file with python3 filename.py from the folder that contains it.
  • Start with Thonny, then move to VS Code.
Lessons are also marked complete when you click Next.

Leave a Reply

Your email address will not be published. Required fields are marked *