Module 2 - Section 0 - Repetition is the mother of knowledge

2.0.1 - Printing in Python

During Module 1 we learned some new concepts that are used widely in Python.
Let's remember them starting with Print command.
As we learned, Print is an output command which sends its results to the screen.
print("Hello World") sends the message Hello World to the screen.
Anything inside the parentheses will be printed on screen, if the syntax is right.
We can print plain text as the previous example (using always the quotes characters "" or ''),

simple numbers,

>>> print(42) 
42

the results of algebric operations inside parentheses (using the standard algebric operations' priority),

>>> print(35*6+7**2)
259

or combinations of the above examples:

>>> print("The second power of 4 equals to",4**2)
The second power of 4 equals to 16

We can also declare that the separator between numbers will be a character instead of the space character:

>>> print(192,168,178,42,sep=".")
192.168.178.42

If we need to print something moving to a new line we use the escape code \n:

>>> print('First line.\nSecond line.')
First line.
Second line.

If we need to print a reserved character we use the character \ and after that the reserved character to be printed:

>>> print("The file is stored in C:\\new folder")
The file is stored in C:\new folder