How to define and use functions in python ?

In this post, we will look how to define and use functions in python.

To understand this, lets see an example below.

Using Functions in Python

In python, the function is defined using “def” keyword.

user@ngelinux$ cat function.py 
#!/usr/bin/python

def hello(name):
  print("Hello how are you %s" %name)

hello("NGELinux User")

user@ngelinux$

Output

user@ngelinux$ ./function.py 
Hello how are you NGELinux User
user@ngelinux$ 

Leave a Reply

Your email address will not be published.