Printing

One of the simplest and most important tasks you can ask a computer to do is to print a message.

In Python, we ask a computer to print a message for us by writing

print()

and putting the message inside the parentheses () and enclosed in quotation marks. Bellow, we ask the computer to print the message “Hello, world!

print("Hello, world!")

Untitled

The code is inside the box (known as code cell), and the computer’s response (called the output of the code) is shown below the box. As you can see, the computer printed the message that we wanted.

Arithmetic

We can also print the value of some arithmetic operation (such as addition, subtraction, multiplication, or division).

For instance, in the next code cell, the computer adds 2 to 1 and then prints the result, which is 3. Note that unlike when we were simply printing text, we don’t use any quotation marks.

print(1+2)

3

We can also do subtraction in python. The next code cell subtracts 5 from 9 and prints the result, which is 4.

print(9 - 5)

4

You can actually do a lot of calculations with python! See the table below for some examples.