Python Tutorial6
Python Tutorial6
Programming language. This program will make use of Python built-in print() function
to print the string.
Steps
The following are the steps to write a Python program to print Hello World –
Step 1: Install Python. Make sure that Python is installed on your system or not. If
Python is not installed, then install it from here: https://www.python.org/downloads/
Step 2: Choose Text Editor or IDE to write the code.
Step 3: Open Text Editor or IDE, create a new file, and write the code to print Hello
World.
Step 4: Save the file with a file name and extension ".py".
Step 5: Compile/Run the program.
Learn Python in-depth with real-world projects through our Python certification
course. Enroll and become a certified expert to boost your career.
In the above code, we wrote two lines. The first line is the Python comment that will be
ignored by the Python interpreter, and the second line is the print() statement that
will print the given message ("Hello World") on the output screen.
Output
Hello World
Example
PS C:\> python
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Example
$ python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Python interpreter also works in scripted mode. Open any text editor, enter the
following text and save as Hello.py
For Windows OS, open the command prompt terminal (CMD) and run the program as
shown below −
C:\>python hello.py
Hello World
$ python3 hello.py
This will display the following output
Hello World
In Linux, you can convert a Python program into a self executable script. The first
statement in the code should be a shebang #!. It must contain the path to Python
executable. In Linux, Python is installed in /usr/bin directory, and the name of the
executable is python3. Hence, we add this statement to hello.py file
Open Compiler
#!/usr/bin/python3
You also need to give the file executable permission by using the chmod +x command
$ chmod +x hello.py
Then, you can run the program with following command line −
$ ./hello.py
Hello World
FAQs
1. Why the first program is called Hello World?
TutorialsPoint developed an online environment where you can run your codes. You can
use the Python online compiler to run your Python programs.
4. First Program Vs Hello World Program in Python?
There is no difference. The first program of Python is generally known as the Hello
World program.
print() method
sys.stdout.write() method by importing the sys module
Using python-f string