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 is used to introduce a new programming language. It is the first program that every beginner writes.
It's okay if you don't understand how the program works. We will learn all about them in upcoming tutorials. For now, just write the exact program and run it.
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.