Skip to Content
👆 We offer 1-on-1 classes as well check now
Python CourseFunctionsWhat Are Functions

What Are Functions

Functions in Python are blocks of reusable code that perform a specific task. They help break your program into smaller, organized pieces, making it easier to read, maintain, and debug.

Why Use Functions?

  • Code Reusability: Write once, use many times.
  • Modularity: Divide large tasks into smaller ones.
  • Abstraction: Hide details and expose only necessary logic.

Function Structure

def greet(name): print("Hello", name)

def: keyword to define a function.

greet: function name.

name: parameter.

print(…): function body.

Calling a Function python Copy Edit greet(“Aarav”) # Output: Hello Aarav yaml Copy Edit

Last updated on