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$ 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments