Python Docs
Installation
Step 1: Check if Python is Already Installed
Open Command Prompt (CMD) and run:
python --version
python3 --version
If you see an error like this, then Python is not installed:
Python was not found; run without arguments to install from the Microsoft Store...
Step 2: Download Python
Visit the official website:https://www.python.org/downloads/
Download the latest stable Python version (e.g., Python 3.13.5).
Choose the correct installer:
- Windows 64-bit → Recommended for most systems (Intel i5/i7, AMD Ryzen)
- ARM version → Only if your device specifically supports ARM
Check the option "Add Python.exe to PATH" during installation. This ensures Python commands work in the terminal.
Step 3: Verify Installation
Open Command Prompt / Terminal and run:
python --version
or
python3 --version
If installed correctly, it will display something like:
Python 3.13.5
Running Python Code
You can run Python programs in the following ways:
1. Python Interactive Shell (REPL) :
Start Python directly in the terminal:
> python
> > > print("Hello")
Hello
This mode is great for testing small code snippets.
2. Running Python Files (.py)
For multi-line code:
- Open an editor or IDE
- Write your Python code
- Save the file with the .py extension, e.g., Demo.py
- Navigate to the folder in your terminal:
> cd path/to/folder
> ls # show files - Run the script:
> python Demo.py
- Output:
Hello
3. Importance of the .py File Extension
The .py extension plays a vital role in Python programming. It identifies a file as a Python script and ensures that tools, interpreters, and IDEs handle the file correctly. Without this extension, the Python interpreter and development tools cannot treat the file as executable Python code.
python script.py
to execute the file successfully.