DEV Community

A K I L A N
A K I L A N

Posted on

Function in python

Function

  • Function is a set of instructions with a name

  • A function can return data as a result

  • Function helps avoiding code repetation

A Function is defined by using def keyword,follwed by a function name and parenteses:

def my_function():
  print("Hello from a function")
my_function();
Enter fullscreen mode Exit fullscreen mode

here def is the keyword,
my_function is the function name,
print() is also function that will give the optput to user,
my_function() will call the function;

Python contains

  • Type of arguments
  • type of function
  • types of variables

Top comments (0)