Open In App

Python Program to Print Hello World

Improve
Improve
Like Article
Like
Save
Share
Report

Hello, World!” is often the first program that programmers learn to write when they start learning a new programming language. It’s a simple program that prints the phrase “Hello, World!” to the console or output window. Python is a high-level, interpreted programming language that is known for its readability and ease of use. Python is often used for scripting, web development, data analysis, machine learning, and more.

Python Program to Print Hello world

Overall, learning how to print “Hello, World!” in Python is a great way to get started with the language and start exploring its capabilities. It’s also a fun and rewarding way to experience the joy of coding and begin your journey as a Python programmer.

Using Print()

Here we will be using the Python print() function for the same. The print() function in Python is used to print Python objects as strings as standard output.

Python3




# python program to print "Hello World"
print("Hello World")


Output:

Hello World

Using sys

In this method we are going to print string using the sys module, sys module in Python provides various functions and variables that are used to manipulate different parts of the Python runtime environment. It allows operating on the interpreter as it provides access to the variables and functions that interact strongly with the interpreter. 

sys.std.write(): stdout is used to display output directly to the screen console.

Python3




# python program to print "Hello World"
import sys
sys.stdout.write("Hello World")


Output:

Hello World

Using a string Variable 

This Python code creates a variable message and assigns it the value “Hello, World!“. Then, the print() function is used to print the value of the message variable to the console.

Python3




# python program to print "Hello World"
message = "Hello, World!"
print(message)


Output:

Hello, World!

Using f-string 

In this case, the f-string contains a single expression that is simply the string “Hello, World!”. When you run this code, you will see the string “Hello, World!” printed to the console output. 

Python3




# python program to print "Hello World"
print(f"Hello, World!")


Output:

Hello, World!


Last Updated : 18 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads