Functions: Add - Numbers A B
Functions: Add - Numbers A B
Functions
● A function is a block of code that performs a specific task and returns a value.
● Functions take inputs (called parameters), process them, and produce an output.
● Example in Python:
Here, add_numbers is a function that takes two inputs (a and b) and returns their sum.
Procedures
def greet(name):
print(f"Hello, {name}!") # Displays a greeting
Here, greet is a procedure because it doesn’t return anything—it just prints a message.
Key Differences
Feature Function Procedure
Returns Yes No
value?