The Hello World Program in Python.
Regardless of the programming language, Hello, World is always the first program that shows how a programmer can begin developing and executing a program. Similarly, we do this in Python and begin our learning process with this basic program.
The following is the Python code for the Hello World program.
#This is the first program a programmer would develop
#to understand the program structure.
print("Hello World");
D:\Python Examples>py HelloWorld.py
Hello World
D:\Python Examples>
Deeper analysis of the Hello Word program.
What follows the #? It is a simple English language but does not have an impact on the program since it is a comment. The comment itself is not an executable statement. Programmers use comments to provide descriptions.
The print function is used to display the string “Hello World”. The function receives a string as an argument and returns the result to the console.
A string is a sequence of characters inside double quotes.
Following is an example of a program that prints Hello World twice.
#Program is printing two Hello Worlds
print("Hello World");
print("Hello World");
D:\Python Examples>py HelloWorld.py
Hello World
Hello World
You can notice a significant difference in the code size if we compare it to C/C++ or Java. There is no need to include header files or import packages. Interestingly the print routing adds a new line after the printing argument.