Hello World Program
Write and understand your first program
Our First Program — Hello World Program
In this section, we will write our very first Python program.
Here is a simple program in the Python programming language that displays the phrase Hello World on the screen:
As you can see, Python only needs a single line. Let's break it down.
The print Function
print is a built-in Python function that outputs text to the screen. To use it, you write the function name followed by parentheses. Inside the parentheses, you pass the text you want to display.
Strings
The text "Hello World" is called a string — a sequence of characters wrapped in quotes. You can use either double quotes " or single quotes ' in Python:
Both lines produce exactly the same output.
No Semicolons, No Braces
Unlike C++, Python does not require semicolons at the end of statements or curly braces {} to define blocks of code. Each line is a complete statement on its own. This makes Python code clean and easy to read.
No main Function Required
In C++, every program must have a main() function as its entry point. In Python, there is no such requirement — the interpreter simply reads and executes your code from top to bottom, line by line.
No Libraries to Import
The print function is available in Python without importing anything. It is part of the language itself, always ready to use.
This program is the simplest possible example of Python in action. Despite its simplicity, it already demonstrates some of Python's core philosophy: code should be readable, concise, and straightforward.