Declaring and Calling Functions

Creating or "Declaring" a Function

Before we can use a user-defined function, we need to create it. To declare a function, you use the def keyword followed by the function name, parentheses, and a colon. You can also specify parameters inside the parentheses if your function needs to accept input values. The function body is indented below the declaration.

Here’s an example of a simple function that takes two parameters and prints their sum:

					def add_numbers(a, b):
    sum = a + b
    print("The sum is:", sum)