Setup Environment

Before we dive into Python programming, we need to set up your development environment. This includes installing Python and choosing a code editor.

Installing Python

  1. Download Python:
  2. Install Python:
    • Run the installer.
    • Make sure to check the box that says “Add Python to PATH” during installation.
    • Follow the installation prompts.
  3. Verify Installation:
    • Open a terminal or command prompt.
    • Type the command:
      python --version
      
    • You should see the installed Python version.

Choosing a Code Editor

A code editor is where you’ll write your Python code. Here are some popular options:

Setting Up VS Code for Python

  1. Install VS Code:
  2. Install the Python Extension:
    • Open VS Code.
    • Go to the Extensions view (Ctrl+Shift+X).
    • Search for “Python” and install the extension by Microsoft.
  3. Verify the Setup:
    • Open a new file and save it with a .py extension (e.g., hello.py).
    • Type the following code:
      print("Hello, Python!")
      
    • Run the file by pressing Ctrl+Shift+B or using the Run option.

Testing Your Setup

  1. Open a terminal in your code editor.
  2. Navigate to the folder where your Python file is saved.
  3. Run the file with:
    python hello.py
    
  4. You should see the output:
    Hello, Python!
    

Now that your environment is ready, you’re all set to begin your Python journey!

Next Lesson: The Terminal