The “Hello, World!” program is a simple introductory program often used to teach the basics of a programming language.
In Python, it’s very a straightforward way to print a message to the screen.
Here is the simple program to print the “Hello, World!” message.
Here’s an explanation of the Python “Hello, World!” program.
print()is a built-in Python function used to display output on the screen.
' ') or double (
" ") quotes. (We will see the details about the Python string in the upcoming tutorial.)
You can execute the Python code on the console, terminal, command prompt, Python shell, or with an online Python compiler.
When you run this program, it will print “Hello, World!” to the console or command prompt, depending on where you are executing it.
To print a “Hello, World!” message in C/C++ or Java, you have to write 5 to 6 lines of code. You have to insert the corresponding library.
Whereas in Python, it is just one line of code.
This is the beauty of Python programming. Python is a very user-friendly and easy-to-learn programming language.
Let’s see some of the interesting examples.
It’s not only about the string, you can also pass the integer or any other numeric value to the “print” function.
You can pass multiple text or parameters to the “print” function, separating them with commas (
You can also perform mathematical operations in the “print” function.
print("Sum ", 45+72)
Next time when you want to perform any calculation, don’t use a calculator. Use Python 😉
When you use addition (
+) operation on numbers, it performs a mathematical addition operation and gives you the sum of those two numbers.
But when you perform the addition (+) operation on strings, it performs a concatenation operation.
print("CSEstack " + "programming tutorials")
CSEstack programming tutorials
Now we see one of the very interesting and useful stuff…
What if you want to print “Python” 10 times?
It will be very cumbersome to write Python 10 times manually.
print("Python " * 10)
Python Python Python Python Python Python Python Python Python Python
When you multiply a string by the number ‘n’, it repeats the string ‘n’ times.
This is the first article as part of our complete Python tutorial. This is all about Python “Hello, World!” program. If you have any doubts, write in the comment section below.