Writing your first Python 3 program is the perfect starting point for beginners — it’s simple, rewarding, and instantly shows you that Python works on your system. The classic “Hello, World!” program prints a message to the screen and confirms your Python installation and basic syntax are correct.

In this beginner-friendly 2025–2026 guide, you’ll learn exactly how to write your first Python 3 program step-by-step: create the file, write the code, run it, understand every part, troubleshoot common issues, and take the next steps to keep learning Python.

Key Takeaways – Writing Your First Python 3 Program

  • Writing your first Python 3 program (“Hello, World!”) verifies Python is installed and running correctly.
  • Use print() — Python’s built-in function to output text to the console.
  • Save files with .py extension and run them with python3 filename.py.
  • Strings go inside quotation marks (“…” or ‘…’).
  • No semicolons or curly braces needed — Python uses indentation for blocks.
  • Works on Windows, macOS, Linux — same code everywhere.
  • Next steps: variables, input, loops, functions — build on this foundation.

Prerequisites

  • Python 3 installed (download from python.org or use system package manager)
  • A text editor (VS Code, Notepad++, nano, PyCharm, IDLE — any works)
  • Terminal/Command Prompt/PowerShell access
  • ~5 minutes

Step 1: Create Your First Python File

  1. Open your terminal (Linux/macOS) or Command Prompt/PowerShell (Windows).
  2. Navigate to a folder where you want to save your code:
				
					cd ~/Desktop/python-projects   # example folder
				
			

       3. Create and open a new file called hello.py:

  • Terminal (nano/vim):
				
					nano hello.py
				
			
  • VS Code:
				
					code hello.py
				
			
  • Any text editor: just create a new file named hello.py

Step 2: Write Your First Python 3 Program

Type (or copy-paste) this single line into hello.py:

				
					print("Hello, World!")
				
			

That’s it — one line!

Save the file:

  • nano: Ctrl+O → Enter → Ctrl+X
  • VS Code: Ctrl+S

Step 3: Run Your First Python 3 Program

In the same terminal folder, run:

				
					C:\Users\chris\Documents\projects\digital o
				
			

Expected output:

				
					Hello, World!
				
			

Congratulations — you just wrote and ran your first Python 3 program!

Understanding Every Part of the Code

Let’s break it down:

  • print() — built-in Python function that outputs text (or numbers, variables, etc.) to the console.
  • (“Hello, World!”) — argument passed to print(). Anything inside quotes is a string.
  • Double quotes ” or single quotes ‘ both work — choose your style.
  • No semicolon ; needed at the end — Python uses new lines and indentation.
  • Filename .py — tells the system this is a Python script.

Try variations to experiment:

				
					print('Hello, World!')          # single quotes
print("Hello", "World!")        # multiple arguments
print("Hello, World!", end='')  # no newline at end
print(42)                       # numbers work too
				
			

Troubleshooting Common Issues

  • Command not found: python3 → Python not installed or not in PATH. Install from python.org or use py on Windows.
  • No output → Forgot to save the file or wrong filename. Double-check hello.py.
  • SyntaxError → Missing quotes, wrong indentation, or typo. Python is strict about syntax.
  • Permission denied → On Linux/macOS: chmod +x hello.py (if running directly), or just use python3 hello.py.

Next Steps After Writing Your First Python 3 Program

Now that you’ve successfully written and run your first program, keep building:

  1. Variables & Data Types
				
					name = "Zain"
age = 30
print(f"Hello, {name}! You are {age} years old.")
				
			

      2. User Input

				
					name = input("What is your name? ")
print(f"Hello, {name}!")
				
			

      3. Simple Calculator

				
					num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
print("Sum:", num1 + num2)
				
			

      4. Loops & Conditions

				
					for i in range(5):
    print(f"Count: {i}")
				
			

      5. Install VS Code + Python extension for auto-complete, debugging, and linting.

How to Write Your First Python 3 Program – FAQ

  1. How do I write my first Python 3 program?
    Create hello.py, add print(“Hello, World!”), save, and run python3 hello.py.
  2. Why is “Hello, World!” the first program?
    It’s the simplest way to confirm Python works and teaches basic syntax/output.
  3. Do I need quotes in print()?
    Yes — anything inside ” ” or ‘ ‘ is a string. Without quotes, Python thinks it’s a variable.
  4. What’s the difference between python and python3?
    On many systems python = Python 2 (old), python3 = Python 3 (current).
  5. Can I run Python without saving a file?
    Yes — type python3 to open interactive mode (REPL) and test lines instantly.

Summary

You’ve just learned how to write your first Python 3 program — from creating the file to running “Hello, World!” and understanding every piece. This tiny program is the foundation of everything else in Python: web apps, data science, automation, AI, games, and more.

Keep going — write one small program every day and watch your skills grow fast!

Recommended Next Tutorials

  • Python Variables & Data Types
  • Python Input & Output
  • Python Loops & Conditions
  • Build a Simple Calculator in Python
  • Install VS Code + Python Extension