Writing to Console (Print statement)

Make your program talk to you!

Print statements are used to print something on the console. Use print("Hello World") to print Hello World in the output screen. We will later learn that print is a function and we use it to perform a print job. Whatever you pass to the print function is printed on the screen. Let’s start by doing a print statement. A print statement allows you to take control of the computer and make it print something out!

We will use printing a lot in the later lessons, so make sure you understand this before moving on to the next concept!

Challenge 1

To start, write the following text into your Repl.it main.py and click Run.

print("Hello, World!")

Watch your console say “Hello, World!” on the screen to the right! print tells the computer to print the sentence within the parentheses () into the console window, or the screen on the right.

alt text

Challenge 2

  1. Without removing the quotation marks, try changing "Hello, World" to another sentence. (For example – "My name is Nuvi!") Press run to see if anything changes.
  2. Add another print below the current line to print a second sentence below the first sentence.
  3. Press run to see if two sentences are printed out.

We will use printing a lot in the later lessons, so make sure you understand this before continuing!

HELP! I got a lot of red text!

If you see any red text, you have encountered some errors! Please ask for help. In particular, beware of the following when coding in Python:

  1. Make sure the sentence you wish to print is surrounded in quotation marks and that the sentence is inside the parentheses.

#Can’t find image

  1. Spacing in Python is very important. Make sure you don’t have any unnecessary spaces or tabs at the beginning or at the end of each line, as Python won’t be able to read the code otherwise. For example, don’t put any spaces before print, or any spaces after the last parenthesis in print("Hello, World!).