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
We will use printing a lot in the later lessons, so make sure you understand this before moving on to the next concept!
To start, write the following text into your Repl.it main.py and click Run.
Watch your console say “Hello, World!” on the screen to the right!
() into the console window, or the screen on the right.
- 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.
- Add another print below the current line to print a second sentence below the first sentence.
- 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:
- Make sure the sentence you wish to print is surrounded in quotation marks and that the sentence is inside the parentheses.
- 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