Python Functions

Last Updated: 01th September 2025


  • Function is a block of code that performs a specific task.
  • It only runs when it is called.
  • Functions help you organize and re-use code.
  • Function are Two Types:
    • User-Defined Functions: Created by you.
    • Built-in Functions: Part of the Python Standard Library.

Hinglish Tip 🗣: Function ko aise samjho—ek “machine” jisme input (parameters) jaata hai aur output (return value) milta hai. Ek baar banao, baar-baar use karo.

User-Defined Functions

Simple rules to define a function in Python:

Built-in Functions

Built-in functions are part of the Python Standard Library and you can use them without installing any additional packages. Some of them are: print(), len(), max(), min(), sum(), map(), filter(), etc.