Python Program to Print Hello World
Beginner · Basics
Hello World is the traditional first program in every programming language: it simply prints the words Hello, World! on the screen. In Python it takes a single line, using the built-in print function.
Program
Hello, World!
How it works
print()is a built-in function that displays whatever you put inside its brackets.- The text
"Hello, World!"is inside quotes, which makes it a string, so Python prints it exactly as written, without the quotes. - The line starting with
#is a comment: Python ignores it, and it is there only for people reading the code. - Single quotes work just as well, so
print('Hello, World!')gives the same output.
Other ways to write it
Say hello to a name
Hello, World! Hello, Asha! Welcome to Python, Asha.
Commas in print() put a space between values, + joins strings with no space, and an f-string drops a variable straight into the text.
Using sep and end
Hello, World! Hello again
sep sets what goes between the values and end sets what comes after them. By default they are a space and a new line, which is why end=" " keeps the next print on the same line.
Try it yourself
Change the program to print your name on one line and your school on the next.
Edit the program above and press Run, or open it in the full editor to save it and share it. To watch it run line by line, open it in the visualizer.
Related programs
All Python programs · CBSE class 12 practical file · Python exercises