Functions are reusable blocks of code that perform specific tasks. They help organize code, reduce redundancy, and improve readability. Here's a breakdown of key concepts:

📌 What is a Function?

A function consists of:

  • Name (e.g., calculateSum)
  • Parameters (inputs)
  • Body (code logic)
  • Return value (output)
def greet(name):
    return f"Hello, {name}!"

🧩 How to Use Functions

  1. Define the function with def keyword
  2. Call it using parentheses
  3. Pass arguments matching parameters
  4. Receive return values if needed

Example:

function add(a, b) {
    return a + b;
}
console.log(add(3, 5)); // Output: 8

📚 Expand Your Knowledge

For deeper insights into programming basics, check our Introduction to Programming tutorial.

📷 Visual Examples

function_definition
function_parameters
function_return_value

Functions are fundamental in any programming language. Master them to build efficient code! 💡