Two ways to practise Python#
- In the browser (right here) - every lesson has a Try it Yourself editor. Perfect for learning.
- On your own computer - needed for real projects, files and libraries. This lesson shows you how.
Step 1: Download Python#
Go to python.org/downloads and download the latest Python 3 version (for example, 3.12 or 3.13).
Always install Python 3. Python 2 is old and officially discontinued since 2020. Code from very old tutorials (like print "hello" without brackets) will not work in Python 3.
Step 2: Install#
On Windows#
- Run the downloaded
.exeinstaller. - Tick the box "Add python.exe to PATH" at the bottom of the first screen. This is very important.
- Click Install Now and wait for "Setup was successful".
On macOS#
Run the downloaded .pkg installer and follow the steps. On a Mac, the command is usually python3 instead of python.
On Linux (Ubuntu)#
Python 3 is usually pre-installed. If not:
sudo apt update
sudo apt install python3 python3-pip
Windows पर install करते समय "Add python.exe to PATH" वाला checkbox ज़रूर tick करें। अगर यह छूट गया, तो Command Prompt में python लिखने पर error आएगा: "python is not recognized..."। ऐसा हो जाए तो installer दोबारा चलाकर Modify चुनें और PATH वाला option tick कर दें।
Step 3: Verify the installation#
Open Command Prompt (Windows) or Terminal (macOS/Linux) and type:
python --version
Python 3.12.4
If you see a version number, Python is ready. (On macOS/Linux use python3 --version.)
Interactive mode (the Python shell)#
Type python (or python3) and press Enter. You will see the >>> prompt:
>>> 5 + 3
8
>>> print("Hello")
Hello
>>> exit()
Every line runs immediately after you press Enter. This is called the REPL (Read-Eval-Print Loop). It is great for quick checks, like a calculator - but nothing is saved.
Script mode (saving your program)#
For real programs, write code in a file:
- Open any editor (Notepad works, but VS Code is better).
- Write your code and save it as
hello.py. - In the terminal, go to that folder and run:
python hello.py
# hello.py
print("Hello from a file!")
print("2 + 2 =", 2 + 2)
Hello from a file! 2 + 2 = 4
Choosing an editor (IDE)#
| Editor | Good for | Notes |
|---|---|---|
| IDLE | Absolute beginners | Comes with Python. Search "IDLE" in the Start menu. |
| VS Code | Students & professionals | Free. Install the Python extension by Microsoft. Most popular choice. |
| PyCharm Community | Bigger projects | Free, powerful, a bit heavy for old laptops. |
| Jupyter Notebook | Data science | Run code in small cells with charts. |
| Google Colab | No installation at all | Runs in the browser, free GPU for AI work. |
Recommended setup: Python 3 + VS Code + Python extension. In VS Code, open your .py file and click the ▶ (Run) button at the top-right.
Interactive vs Script mode#
Interactive mode (>>>) |
Script mode (.py file) |
|---|---|
| Runs one line at a time | Runs the whole file |
| Shows results automatically | You must use print() to see results |
| Code is lost when you close it | Code is saved and reusable |
| Best for quick tests | Best for real programs |
In interactive mode, typing 5 + 3 shows 8. But in a .py file, the line 5 + 3 shows nothing - you must write print(5 + 3).
Summary#
- Download Python 3 from python.org; on Windows tick Add python.exe to PATH.
- Check with
python --version. >>>= interactive mode (quick tests);.pyfiles = script mode (real programs).- Use VS Code with the Python extension for daily work.