9 Dec 2019

How to Print Hello World in Python Programming?

Welcome To Python in two different Lines using a single print().

Creating a Program where it Print Hello World in Python

Let me try to show how using a single print() we can print different statements in different lines. The necessary codes will be like this –

# Program To Print Hello World. Welcome To Python in two different Lines

print(“Hello World.\nWelcome To Python”)


Hello World Program in Python

Print Hello World in Python

Now Look at the coding part – the first line, of course, is a comment statement. But then we have used print(“Hello World.\nWelcome To Python”) – this statement is producing the required output and due to use of \n – Welcome To Python is appearing in the next line.

Here \n is used here as a newline character. Of course a C/C++ programmer might be already very much familiar with the usage of \n as a new line character. 

Now you can write the necessary codes and test it in your machine.  The output is already shown in the figure above. The following table can give some other varieties of using \ –

Symbols Explanation
\n Used to Create a New Line
\t Used to Create a Tab Space
\\ Used to Represent backslash character (\)