What is "Hello World" program?
"Hello World" program is a simple conventional program used by programmers to demonstrate the basic syntax of a programming language. It typically consists of a piece of programming code that prints the phrase "Hello World" to the output (console).
In Python, "Hello World" program is used to demonstrate the basic syntax of Python and display (print) the phrase "Hello World" on the console.
Creating Hello World Program in Python
-
Create a Python file (with
.py
file extension) and open the file in your favorite Python code editor. You can also write the code in the Online Python Editor of xfactorschool.com, which is very easy to use for the beginners. -
Write Python code
print("Hello World")
in the file and run the program.
In the above code, print()
is a built-in Python function that is used to output text or other data to the console or standard output.
Hello World
is the text that will be displayed as output when the program is executed.
Please take a closer look at the following example that you have already created:
Example of Python Hello World Program
Output of the above example
Hello World
Double Quotes or Single Quotes for Text
In Python, double quotes (" ") or single quotes (' ') are used to define string.
In the following example, the message Welcome to Python World.
has been printed using double quotes as well as single quotes. The output will be same.
Examples of Double Quotes and Single Quotes
Output of the above example
Welcome to Python World. Welcome to Python World.