How to Use Function in Python Programming Language

Posted on


In Python programming languages, there are lots of functions available such as print, sum, len, etc. Moreover, aside from the built-in functions which is available upon successing on installing python, there are also another type of functions. Python enable programmer or developer in order to make a new function which is part of the journey on developing program or applications itself.

Getting help

In the context of using a built-in functions available in python there must be some sort of difficulties. Actually, it is because there are lots of available functions in python such as print, sum, len, etc. Because of the amount of functions available, whenever the time come to use those functions, there are some situations where the name of the function itself cannot be remembered.

Fortunately, python provides another function to help finding other functions. That function is the help() function. It is one of the most important function available in python. Since remembering only one function will help to be able to search for another functions this will be very helpful. By using this function, most of the other function is still in reach. So generally speaking, this function will be able to help to understand the usage of other functions. The following is an example to use the help function :

>>> print(help(print))
Help on built-in function print in module builtins:
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.


The help() function above will present two things :

  1. Header : the header is the first part of the help function output. The above example is using the print part which is print(…). This line inform that the function will accept an argument of string.
  2. Description : the description part will actually inform about the usage of that function. In this context, the print function will prints the values to a stream, or to sys.stdout by default.

Leave a Reply