In the previous tutorial, you learned how to install Python on your computer. Now, let's write a simple Python program.
The following program displays Hello, World!
on the screen.
print("Hello, World!")
Output
Hello World!
Note: A Hello World!
program includes the basic syntax of a programming language and helps beginners understand the structure before getting started. That's why it is a common practice to introduce a new language using a Hello World!
program.
Working of the Program
Congratulations on writing your first Python program. Now, let's see how the above program works.
In Python, anything inside print()
is displayed on the screen.
There are two things to note about print()
:
- Everything we want to display on the screen is included inside the parentheses
()
. - The text we want to print is placed within double quotes
" "
.
We can also use single quotes to print text on the screen. For example,
print('Hello World!')
is same as
print("Hello World!")
To be consistent, we will be using double quotes throughout the tutorials.
Next, we will be learning about Python comments.