What is python function

Python Function

  • The Python function is defined by a def statement. The syntax looks like this: def function-name (Parameter list): statements, i.e. the function body. The parameter list contains none or more parameters. Parameters are known as arguments, if the function is called.
  • A python function is a “callable” (which just means something you can invoke) that repeats a set of steps that you pre-define.
    • Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
    • Any input parameters or arguments must be placed within these parentheses. Now you will define the parameters within the parentheses.
    • The initial statement of a function is optional – the documentation string of the function (docstring).
    • The code block within every function starts with a colon (:) and is indented.
    • The statement return [expression] exits a function, optionally passing back an expression to the caller. The return statement with no arguments is the similar as return none.

Syntax :

def functionname( parameters ):
   "function_docstring"
   function_suite   
   return [expression]

Categorized in:

Python

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Share Article:

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock