It is a tradition in Computer Science for your first program to be “hello world”. The “hello world” program always prints the words “hello world” on the console (*the console is the the most basic output of any program and only outputs text).
In Python we can output text to the console using the “print” function, also known as the “print” method (a function and a method are the same thing).
The code below will print “hello world” to the console.
print ("hello world")
Note that the code above is just print (“hello world”). The number 1 is the line number, just used for reference. And the colors just make it easier to read, more on that later later.
Technically the code above works fine but as Computer Scientists we always want to be sure to add comments to our code so that other humans can understand the code easier. In Python we can add comments on a line by beginning that line with the # symbol. Lines that begin with the # symbol will be ignored by the computer and are just for humans to read.
I will now add some comments to my Hello World program to give other humans some information about my program
#Author: Mx. Epstein #Email: mxepstein@mxepstein.com #Date: 13-11-2015 #License: Apache-2.0 #The line below prints the words "hello world" print ("hello world")
Below I’ve included this code in a trinket so that anyone with a trinket.io can remix it to make it their own. Learn how to use trinkets on the About Trinkets page