Python program to print hello world
Prerequisite: Python Language Introduction, Python 3 basics
In this article, we will look into How to print “Hello World” in Python.
Method 1: 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.
The python print function has the following syntax:
Syntax: Print(“string”)
Where: String: This string will be “Hello world”
Implementation:
Python3
# python program to print "Hello World" print ( "Hello World" ) |
Output:
Hello World
Method 2: 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.
Syntax: sys.stdout.write(“String”)
Code:
Python3
import sys sys.stdout.write( "Hello World" ) |
Output:
Hello World
Please Login to comment...