Python | Print Hello world using function

Today in this article, we will talk about how to print “Hello World”, but the only catch is that we will not use the simple print() function to do so, instead we will be using the user function to perform the printing part. In total, we will go through two methods. So, let us move on to the coding for this.

Different methods to print Hello world using the function

Method 1: Using a simple process (without parameters)

def greet_world():
    print("Hello World")



Here in this above code, we declared a function, wherein inside that we used a print() function and then we called that function greet_world()


Hello World

Method 2: Using a simple process (with parameters)

def greet_world(greetings,to_whom):
    print(greetings + " " + to_whom )
greetings = str(input("Enter your word for greetings: "))
to_whom = str(input("Whom you want to address: "))


In this method on Python Program to print Hello world using the function, we have used a function named greet_world() and that is the function in which we have passed the two parameters. Initially, we declared two variables that basically took the input from the user and then passed on those two variables as parameters to the function and simply printed that message using string concatenation. This is quite a long method as we have used multiple concepts of python like string concatenation, functions, etc.


Enter your word for greetings: hello
Whom you want to address: world
hello world
Avatar of Dhvanil V

Author: Dhvanil V