1.3: The first program
- Page ID
Traditionally, the first program you write in a new language is called “Hello, World!” because all it does is display the words “Hello, World!”. In Python, it looks like this:
>>> print('Hello, World!')
This is an example of a print statement, although it doesn’t actually print anything on paper. It displays a result on the screen. In this case, the result is the words
The quotation marks in the program mark the beginning and end of the text to be displayed; they don’t appear in the result.
The parentheses indicate that
In Python 2, the print statement is slightly different; it is not a function, so it doesn’t use parentheses.
>>> print 'Hello, World!'
This distinction will make more sense soon, but that’s enough to get started.