shlogg · Early preview
Ranjith Srt @ranjithsrt

Understanding Functions In Python Basics

Functions in Python are blocks of code that run when called, can take parameters and return data. They're defined with the `def` keyword. Example: `def python(): print("Hello world")`.

function
A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
A function can return data as a result.
def python():
  print("Hello world")
Calling a Function:
``def python():
  print("Hello world, python ")
Python ()``
Arguments
Information can be passed into functions as arguments.
Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.
`def p_name(name, age):
     Print ("name :" +name +"age :" +age) 
p_name ("dhoni", "39" ) 
Output...