Python Program to Print Hello World

In this article, we will go through our first python program to print hello world.

We can print it in two ways. They are –

Method 1. – Using print() method

print() function is used to print python object as strings as standard output.

Syntax

print(“STRING_VALUE”)

In our case, STRING_VALUE will be “Hello World”.

Now, we are going to print hello world.

print("Hello World") // This line in python program prints "Hello World" 

When you run program, “Hello World” will be print as standard output.

Method 2. – Using sys module

sys module in python can be used to manipulate different paths of python runtime environment.
We can use sys.stdout.write() to print output to console.

Syntax

sys.stdout.write(“String”)

Implementation

sys.stdout.write("Hello World")

Here, “Hello World” will be printed to console.

Leave a Reply