Functions are blocks of statements that perform a specific task.

Function has two parts
|---- Definition → where we write logic
|---- Call → where we use (invoke) it
 
Write once → reuse many times
  • function definition
def function_name():
    # multiple statements

example

def hello():
    print("hello")
 
hello()   # function call

output

hello

Note

After defining a function, we must call it to use it.

Function Types
|---- User-defined → created by user
|---- Built-in → already available
 
Built-in examples:
print(), input(), type(), range()