Printing "Hello, World!" is a kind of ritual that start the journey every programmer.
According to Wikipedia:
A "Hello, World!" program generally is a computer program that outputs or displays the message "Hello, World!". Such a program is very simple in most programming languages, and is often used to illustrate the basic syntax of a programming language. It is often the first program written by people learning to code.
In this post I will show you how to print "Hello, World!"
in Python
This is first post and I am scared
Step 1: Download and Install Python
[skip this step if you have already installed it]
Just head to https://python.org/download/ and download the install the program supported by your os, i.e. .msi for windows and .dmg for mac
In the windows you have to tick the check box saying Add Python3.xx to path
For Linux you have to open an application named terminal and type the following command, make sure you are connected to internet and have sudo
privilege.
Command to install python on Linux
sudo apt-get install python3.8
Step 2: Writing the program
Open a suitable text editor of your choice and type the following code and save it in .py
extension
print("Hello, World!")
Here we are printing the "Hello, World!" with print
function.
It is a built-in function in python which helps to print thing in the console window
If you wish you can skip this section
The print
function have the following arguments
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Step 3: Running the program
In windows, open the folder in where is your program is located and press shift + right click
to open the context menu and select the Open with powershell
option
In Linux/Unix, open the folder in where is your program is located and press right click
to open the context menu and select the Open in Terminal
option
Now in the terminal type the following command
For Windows
python app.py
For Linux/Mac
python3 app.py
The following thing will be print
Hello, World!
So that was a simple tutorial on how to print "Hello, World!" in Python.
Well then see you all next time.
Peace ✌
Top comments (1)
Looks like I have written a too long article for a very simple thing
😛😓