2.Complete Python Basics for Automation- Python setup on Windows

2 min read 1 hour ago
Published on Nov 06, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of installing Python on a Windows system, which is essential for anyone looking to automate tasks using Python. This setup is particularly beneficial for network engineers and beginners who want to dive into Python programming.

Step 1: Download Python

  1. Open your web browser and go to the official Python website: python.org.
  2. Navigate to the "Downloads" section.
  3. Choose the latest version of Python for Windows and click on the download link.
  4. Wait for the installer to download to your system.

Step 2: Run the Installer

  1. Locate the downloaded installer file, usually found in your "Downloads" folder.
  2. Double-click the installer to run it.
  3. Important: Check the box that says "Add Python to PATH." This ensures you can run Python commands from any command prompt.
  4. Click on "Install Now" to begin the installation process.

Step 3: Verify the Installation

  1. Once the installation is complete, open the Command Prompt:
    • Press Windows + R, type cmd, and hit Enter.
  2. In the Command Prompt, type the following command and hit Enter:
    python --version
    
  3. If Python is correctly installed, you should see the version number displayed.

Step 4: Install a Code Editor

  1. Choose a code editor for writing Python scripts. Common options include:
    • Visual Studio Code
    • PyCharm
    • Atom
  2. Download and install your preferred editor from its official website.

Step 5: Write Your First Python Script

  1. Open your code editor.
  2. Create a new file and save it with a .py extension (e.g., hello.py).
  3. Write a simple Python script:
    print("Hello, World!")
    
  4. Save the file.

Step 6: Run Your Python Script

  1. Go back to the Command Prompt.
  2. Navigate to the directory where your script is saved using the cd command:
    cd path\to\your\script
    
  3. Run the script by typing the following command:
    python hello.py
    
  4. You should see "Hello, World!" printed in the Command Prompt.

Conclusion

You've successfully installed Python on your Windows system, verified the installation, and run your first Python script. This foundational setup allows you to explore Python programming further, especially in the context of automation and network engineering. As next steps, consider diving into Python basics, such as data types, functions, and control flow statements, to build your skills.