Python
    About Lesson

    Installing Python on your computer is simple and can be done in just a few steps. Follow this guide to get started with Python.

    Python is a versatile programming language widely used for web development, data analysis, artificial intelligence, and more. Here’s a step-by-step guide to installing Python on your system with examples to get started.

    Download Python Installer

    First, you need to download the Python installer from the official Python website. Go to https://www.python.org/downloads/ and choose the version of Python you want to install. For beginners, it’s recommended to download the latest stable version.

     

    Run the Installer

    Once the installer is downloaded, locate the file and double-click on it to run it. You may need administrative privileges to install Python on your system.

     

    Install Python

    For Windows:

    1. Run the downloaded .exe file.
    2. In the installer:
      • Check the box “Add Python to PATH” (important for command-line usage).
      • Click Install Now or customize the installation if needed.
    3. Wait for the installation to complete and click Close.

    For macOS:

    1. Open the downloaded .pkg file.
    2. Follow the installation wizard and complete the setup.
    3. After installation, verify it using the terminal.

    For Linux:

    1. Open the terminal.
    2. Update the package list:
      sudo apt update
    3. Install Python:
      sudo apt install python3
    4. Verify the installation:
      python3 --version

     

    Customize Installation (Optional)

    During the installation process, you may be prompted to customize the installation. You can choose the installation directory, add Python to your system’s PATH, and select optional features. For most users, the default settings should be sufficient.

     

    Start Installation

    After customizing the installation settings (if needed), click on the “Install Now” button to start the installation process. The installer will copy the necessary files and configure Python on your system.

     

    Verify Installation

    Once the installation is complete, you can verify that Python has been installed successfully by opening a command prompt (on Windows) or a terminal (on macOS or Linux) and typing the following command:

    python --version

     

    This command will display the installed version of Python. If you see the version number, it means Python has been installed successfully.

     

    Run a Python Script (Optional)

    To test Python installation further, you can create and run a simple Python script. Open a text editor (such as Notepad on Windows or TextEdit on macOS) and create a new file with the following content:

    print("Hello, Python!")

     

    Save the file with a .py extension, for example, hello.py.

    Open a command prompt or terminal, navigate to the directory where you saved the hello.py file, and then run the following command:

    python hello.py

     

    You should see the output Hello, Python! printed to the console, indicating that Python is working correctly.

    You’ve successfully installed Python on your system. Now you’re ready to start writing and running Python code.