DEV Community

Nandhini
Nandhini

Posted on

Functions in Python

A block of code or to perform specific task or set of instruction, with a name is a function.

How to create a function in python?
There is a keyword to create function, it is def (definition)...
_Eg.,

def play():
         calling friends
         taking necessary items
         going to ground

Enter fullscreen mode Exit fullscreen mode

python don't have brackets. It uses indentation... And, when two function created in same name, python will automatically chooses the later one and prints the output...

Why we need to learn function?

  1. Code reusability
  2. Easy maintanance
  3. Redeability
  4. Modularity _

Top comments (0)