Intro to Python

1. Hello World!

The “Hello World!” program is the first step in learning how to code with any language. This tradition was first established in the 70s by Nokia Bell Labs and has since advanced into the famous first line of code that most programmers write. It is a program that prints the text “Hello World!” to some output stream, usually the console, and it’s primarily taught for three purposes:

  1. To illustrate the basic syntax of a language.
  2. To check that you have correctly installed your computer language
  3. To teach printing. Printing is a handy tool because you can use it for debugging regardless of what language or IDE you are running.

Printing

Printing in computer science is getting the computer to print out specific text into an output stream, as mentioned above.

Here are some examples of how printing works:

print("Hello World!")
> Hello World
print("I am learning how to program in Python!")
> I am learning how to program in Python!
print("I like to eat pizza!")
> I like to eat pizza!

Note: When you print text, everything between the quotation marks is printed to the output.

Entry points

Another important beginner concept is entry points. Entry points are where your program will begin to run.

Python is executed differently from Java and C++. It simply runs all code from the very first line to the very bottom line, and this means you don’t need to mark any entry points like in Java or C++. The Python code below, for example, will run fine on its own.

print("Python doesn't require you to mark any entry points")
> Python doesn't require you to mark any entry points

Note: It’s possible to structure your code in Python to define an entry point that isn’t the first line, but it isn’t necessary to get the code running.

You can play with all the code we've used in this article on Trinket: