"Hello, World!" is the traditional way to begin learning a new programming language. It is a simple program that displays a greeting on the screen and introduces the new language by showing its syntax and program structure.
We're not breaking this tradition since it is over forty years old. In the first lesson, we'll write a program called Hello, World!
. To do this, you need to give the computer a special command. That is print()
in Python:
print('Hello, World!')
# => Hello, World!
We used a comment to explain more about what value is displayed.
How comments work
Almost all programming languages allow you to leave comments on your code. The interpreter ignores them. They're only for people; they let the programmer make notes for themselves and other programmers.
They allow you to add explanations of how the code works, what errors need to be corrected, or what you need to remember to add later:
# Delete the line below after you finish the registration task
print(10)
In Python, comments begin with the #
sign and can appear anywhere in the program. They can take up an entire line. If one line isn't enough, you can create several comments:
# For Winterfell!
# For Lannisters!
The comment can be on the line after the code:
print('I am the King')
# For Lannisters!