3. First Program

In this lesson you will write your first program and learn how a computer reads code.

Hello World

Hello World is an infamous and simple program that is used to showcase the basic syntax of a programming language. For us, Hello World would be:

print("Hello World!")

Make sure to save the program and run it. In the console you should see the message Hello World! Congratulations, you have created your first program.

How Did This Work?

It is one thing to create a program and another to understand what is going on. Let's break down what happened. First, the print function was called and we told the function to print Hello World! Then the computer reads the code and in return did what we asked it to do.

In a later lesson you will learn what a function is but for now just know it is code already written for you that accomplish a specific task, in this case it "printed" to the console.

What Else Can We Do?

One of the best ways to learn is to experiment and test out new things. Now, lets try to print your name. For example, for me it would be:

print("Andrew is awesome")

And voilà! Now in the console it says Andrew is awesome. Now try to put multiple lines of code. For example:

print("coding")
print("is")
print("fun!!!")

Notice how computers read code from top to bottom; First printing the code in line one, then line two, and so on.

As you can see, each print statement was sent on its own line but what if we wanted multiple lines with one print function? To do this, we could use either multiple quotes or escape characters. An example of multiple quotes would be:

print("""coding
	is
	awesome""")

In Python, escape characters are all done with a backslash, \. Below are some examples of the usage of escape characters:

print("backslash: \\")
print("newline: \n")
print("tab: \t")
print("single quote: \'")
print("quotes: \"")
❮ PreviousNext ❯