Week 1 - Section 1 - Input and Output

In the first section of the first week we will learn how to send the output of a program to the screen and how to read from the keyboard.

Chapter 1.1 - Printing Text

1.1 Printing Text

How does a program print something to the screen? The code is simple. Just one line is required:

print("Hello World.")

This program prints out “Hello World” to the screen. Go ahead and enter it into the CLI prompt and see how it works. Try printing other words and phrases as well. The computer will happily print out just about anything you like, true or not.

Remember, the command for printing in Python is easy. Just use print. After the print command are a set of parentheses (). Inside these parentheses is what should be printed to the screen. Using parentheses to pass information to a function is standard practice in math, and computer languages.

Notice that there are double quotes around the text to be printed. If a print statement has quotes around text, the computer will print it out just as it is written. For example, this program will print 2+3:

print("2+3")

Go ahead and try it entering the expression inside the CLI.