Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Industrial programming >> Python

Getting Started with Python: Install, Run, and Write Your First Program

Getting Started with Python: Install, Run, and Write Your First Program

This guide walks you through installing Python on any operating system, running it via Thonny or the command line, and creating your first “Hello World” program.

Video: Introduction to Python

Python is a cross‑platform, open‑source programming language that runs on Windows, macOS, Linux, and even the Java and .NET virtual machines. While many Linux and macOS distributions ship with Python pre‑installed, the bundled version may be outdated. Installing the latest release ensures you have access to the newest features and security updates.


The Easiest Way to Run Python

For beginners, Thonny IDE is the most straightforward option. It bundles the latest Python interpreter, eliminating the need for a separate installation.

  1. Download Thonny from the official website.
  2. Run the installer and follow the on‑screen prompts to install Thonny.
  3. Open Thonny, go to File > New, and save your script with a .py extension (e.g., hello.py).
  4. Write your Python code, then press Run > Run current script or hit F5 to execute.

Install Python Separately

If you prefer a standalone installation, follow these steps:

  1. Download the latest Python release from python.org.
  2. Run the installer. During setup, check Add Python to environment variables so you can invoke Python from any terminal.
  3. Optionally, choose a custom installation directory.
    Getting Started with Python: Install, Run, and Write Your First Program

After installation, you can launch Python from the command line.


1. Run Python in Immediate Mode

Open a terminal and type python (or python3 on macOS/Linux). The interpreter starts, allowing you to type expressions directly:

Getting Started with Python: Install, Run, and Write Your First Program

Try entering 1 + 1; you’ll see 2 as the output. Type quit() to exit.


2. Run Python in an Integrated Development Environment (IDE)

While any text editor can write Python code, an IDE provides code hinting, syntax highlighting, and project management tools. Python’s bundled IDE, IDLE, is a solid choice for beginners.

Open IDLE, create a new file (File > New File), save it with a .py extension, and write your script. Execute it with Run > Run Module or press F5:

Getting Started with Python: Install, Run, and Write Your First Program
Getting Started with Python: Install, Run, and Write Your First Program

Your First Python Program

Now that Python is up and running, let’s create a classic beginner’s program: Hello World. It prints a friendly greeting to the console.

print("Hello, world!")

Save the file as hello_world.py and run it. You’ll see:

Hello, world!

Congratulations! You’ve written and executed your first Python program. Python’s simplicity and readability make it an excellent starting point for deeper exploration.


Python

  1. Retrieve Current Date and Time in Python: A Practical Guide
  2. How to Get Started with 3D Printing for Maximum Business Impact
  3. Python Print() Function: A Practical Guide with Examples
  4. Launching Your Manufacturing Business into E‑Commerce: A Practical Guide
  5. Master International Shipping: A Practical Guide for Retailers & Manufacturers
  6. Begin Your Industry 4.0 Journey: A Practical Guide
  7. Master Edge AI Inferencing: A Practical Guide to Actionable Insights
  8. Beginner’s Guide to Yaskawa Motoman Robot Programming: Boost Speed & Accuracy
  9. Beginner’s Guide: Setting Up RoboDK on Raspberry Pi
  10. Beginner's Guide to 3D Printing: Start with Confidence