How to Write First Python Program

Learn how to write your first program, “Hello, World!” This tutorial covers basic syntax, running your code, and understanding essential beginner concepts.

First Python Program Hello World

New to Python? Start here.

Your first program is a tradition: “Hello, World!”. This lesson shows you how to write and run it.

Free Course

Python Fundamentals for Beginners Free Course

Master Python basics, from variables to data structures and control flow. Solve real-time problems and build practical skills using Jupyter Notebook.

13.5 hrs
4.55
Enroll for Free

Why “Hello, World!”?

It is a simple program. It shows you know the basic syntax. It is a tradition for starting any programming language.

The Code

Open a text editor. Type this:

print("Hello, World!")

Save the file. Name it hello.py.

What This Code Does

print() is a function. A function is a block of code. It runs when you call it. The print() function shows messages on the screen.

“Hello, World!” is a string. A string is text. The text must be in quotes.

Run Your Code

Go to your terminal or command prompt. Navigate to the folder where you saved hello.py.

Type this command and press Enter:

python hello.py

The Output

You will see this on your screen:

Hello, World!

You just wrote your first Python program.

Common Questions

  • Do I need the quotes (“”)? Yes. The text inside print() must be a string, so it needs quotes.
  • What are the parentheses () for? They are part of the function’s syntax. The information inside is called an argument.
  • Why print? It’s a built-in Python function that outputs text to the console.

This lesson is a part of the Python Tutorial.

Next: How Python Code Runs
Previous: Choosing a Python IDE or Editor

Avatar photo
Great Learning Editorial Team
The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.
Scroll to Top