Your First Python Program: A Step-by-Step Guide

Learn Python @

Welcome to the world of Python programming! If you’re new to coding or just starting with Python, this article will guide you through creating and running your first Python program. We’ll explore basic Python syntax, printing, and fundamental concepts with hands-on examples and outputs, ensuring a smooth start to your Python journey.

Python: A Brief Introduction

Python is a versatile and beginner-friendly programming language known for its simplicity and readability. It’s an excellent choice for both beginners and experienced developers due to its wide range of applications, from web development and data analysis to artificial intelligence.

Setting Up Your Python Environment

Before you write your first Python program, you’ll need a Python interpreter installed on your computer. If you haven’t already installed Python, refer to our previous article on “Setting Up Your Python Development Environment.”

Writing Your First Python Program

Let’s start by creating a simple Python program that prints “Hello, Python!” to the console. Follow these steps:

Step 1: Open a Text Editor

You can use any text editor to write Python code. Common choices include Notepad (Windows), TextEdit (macOS), or code editors like Visual Studio Code, Sublime Text, or PyCharm.

Step 2: Write the Python Code

In your text editor, write the following Python code:

# Your First Python Program
print("Hello, Python!")

This code consists of a single line that uses the print() function to display the text “Hello, Python!” on the screen. Python code is easy to read and understand, making it ideal for beginners.

Step 3: Save the File

Save your file with a .py extension, such as This extension indicates that the file contains Python code.

Step 4: Run Your Python Program

To run your Python program, open your terminal or command prompt and navigate to the directory where you saved your file.

Use the following command to execute the program:


Example Output:

Hello, Python!

Congratulations! You’ve just written and run your first Python program.

Understanding the Code

Let’s break down the code you’ve written:

  • # Your First Python Program: This line is a comment. Comments are not executed but provide explanations for your code.
  • print("Hello, Python!"): This line uses the print() function to display the text “Hello, Python!” on the screen. The text is enclosed in double quotes (") to indicate it as a string.
Author: user