Featured Article

"Python Hello World: Your First File in 5 Steps"

Christopher Jun 29, 2026

Creating Your First Python Program: Hello, World!

كود مرحبا للعالم في بايثون The Hello World Code in Python
كود مرحبا للعالم في بايثون The Hello World Code in Python

Welcome to the exciting world of Python programming! Like any new language, the best way to start is by creating a simple "Hello, World!" program. This guide will walk you through creating and running a Python "Hello, World!" file, step by step.

print("Hello world!!")
print("Hello world!!")

Setting Up Your Python Environment

Before you start, ensure you have Python installed on your computer. You can download it from the official Python website: Python Downloads. Once installed, open your terminal or command prompt and type:

Hello, World! Iconic Programming Phrase Art
Hello, World! Iconic Programming Phrase Art

python --version

This should display the installed Python version. If it's installed correctly, you're ready to go.

Creating Your Hello, World! File

some type of text that is in the language hello world with different types of words
some type of text that is in the language hello world with different types of words

Open your favorite text editor or Integrated Development Environment (IDE) like Visual Studio Code, PyCharm, or Jupyter Notebook. Create a new file and save it with a .py extension, for example, hello_world.py.

Writing Your First Line of Code

In your new file, type the following line:

an image of a cartoon character climbing the stairs
an image of a cartoon character climbing the stairs

print("Hello, World!")

This is a simple Python statement that prints "Hello, World!" to the console.

Running Your Python File

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

Writing First Code in Python (Hello World) - The Engineering Projects
Writing First Code in Python (Hello World) - The Engineering Projects

python hello_world.py

You should see "Hello, World!" printed to the console.

Understanding the Code

the words hello world written in green on a black background
the words hello world written in green on a black background
what is file handling in pyrton? infographical poster on blackboard
what is file handling in pyrton? infographical poster on blackboard
an info sheet with the words, how do you write hello world? and some type of text
an info sheet with the words, how do you write hello world? and some type of text
how to stick stickers on laptop | "Python code - print('Hello World') - Hello World coding" Mag
how to stick stickers on laptop | "Python code - print('Hello World') - Hello World coding" Mag
Python File Handling Explained for Beginners (Complete Guide)
Python File Handling Explained for Beginners (Complete Guide)
Hello world program in python
Hello world program in python
Write your first python Program | Hello World
Write your first python Program | Hello World
python
python
Programming Terminology Guide, Basic Python Dictionary Tutorial, How To Iterate Over A Dictionary In Python, Programming Language Terms, Python Dictionary Keys And Values, How To Create A Nested Dictionary In Python, How To Make A Nested Dictionary In Python, How To Sort Dictionary By Key In Python, Python File Methods Dictionary
Programming Terminology Guide, Basic Python Dictionary Tutorial, How To Iterate Over A Dictionary In Python, Programming Language Terms, Python Dictionary Keys And Values, How To Create A Nested Dictionary In Python, How To Make A Nested Dictionary In Python, How To Sort Dictionary By Key In Python, Python File Methods Dictionary
File Handling in Python
File Handling in Python
a black background with different types of text and symbols on the bottom right hand corner
a black background with different types of text and symbols on the bottom right hand corner
a poster with many different types of logos and numbers on it, including the words'life is short, use python '
a poster with many different types of logos and numbers on it, including the words'life is short, use python '
Python For Everything – Top Libraries & What They’re Used For
Python For Everything – Top Libraries & What They’re Used For
🐍 Python — For Everything! 💻✨
🐍 Python — For Everything! 💻✨
Introduction to Python: Basics of Programming
Introduction to Python: Basics of Programming
a screenshot of a computer screen with the words python string method in front of it
a screenshot of a computer screen with the words python string method in front of it
the words and numbers are written in different languages, with cats sitting on top of each other
the words and numbers are written in different languages, with cats sitting on top of each other
an image of a computer screen with many lines and numbers on it, all in different colors
an image of a computer screen with many lines and numbers on it, all in different colors
Hello World written in Python Vinyl Sticker - Kiss-Cut for Laptops & Notebooks, 4 Sizes
Hello World written in Python Vinyl Sticker - Kiss-Cut for Laptops & Notebooks, 4 Sizes

The print function in Python is used to output data to the console. In this case, we're printing a string, "Hello, World!". The text inside the parentheses is the argument passed to the function.

Exploring Further

Now that you've created your first Python program, let's explore a few variations:

  • Printing Variables: You can store the text in a variable and print it. Here's how:

message = "Hello, World!"
print(message)
  • Printing with Formatting: You can also print text with variables using string formatting. Here's an example:

name = "Alice"
print(f"Hello, {name}!")

This will print "Hello, Alice!"

Best Practices

Here are a few best practices to keep in mind:

Best Practice Explanation
Use Descriptive Names Instead of using single letters or words like 'a' or 'msg', use descriptive names like 'user_greeting' or 'message_to_print'.
Keep Lines Short Python has a maximum line length of 79 characters, but it's a good practice to keep lines shorter for readability.

That's it! You've just created and run your first Python program. As you continue learning, you'll build on these basic concepts to create more complex and powerful programs.