Last modified: Feb 04, 2026 By Alexander Williams

How to Call a Function in Python

Calling a function is a core skill in Python. It is how you run the code inside a function. This article will show you how.

You will learn the basic syntax. We will cover passing information to functions. You will also see how to use the results they give back.

What is a Function Call?

A function is a reusable block of code. It performs a specific task. To use it, you must call it.

Calling a function means asking Python to execute its code. You do this by writing the function's name followed by parentheses.

Think of it like using a tool. Defining a function is like having the tool. Calling it is like actually using it to do a job.

The Basic Syntax for Calling a Function

The syntax is simple. Use the function name and parentheses ().


# Define a simple function
def greet():
    print("Hello, World!")

# Call the function
greet()
    

Hello, World!
    

In this example, greet() is the function call. Python runs the code inside the greet function definition.

The parentheses are crucial. They tell Python you want to execute the function. Forgetting them is a common mistake.

Calling Functions with Arguments

Functions often need data to work with. This data is passed as arguments inside the parentheses.

Arguments are the actual values you give to the function. They match the parameters defined in the function.


# Define a function with a parameter
def greet_person(name):
    print(f"Hello, {name}!")

# Call the function with an argument
greet_person("Alice")
greet_person("Bob")
    

Hello, Alice!
Hello, Bob!
    

Here, "Alice" and "Bob" are arguments. They are passed to the name parameter. For a deeper look at defining functions, see our Python Function Syntax Guide for Beginners.

You can pass multiple arguments. Just separate them with commas.

Using Return Values from a Function Call

Many functions calculate a result. They send this result back using a return statement.

When you call such a function, it produces a value. You can store this value in a variable or use it directly.


# Define a function that returns a value
def add_numbers(a, b):
    result = a + b
    return result

# Call the function and capture the return value
sum_result = add_numbers(5, 3)
print(f"The sum is: {sum_result}")

# Use the return value directly in an expression
print(f"Ten more is: {add_numbers(sum_result, 10)}")
    

The sum is: 8
Ten more is: 18
    

The return statement is key. It specifies what value the function call evaluates to. Without it, the function returns None.

Calling Built-in Python Functions

Python comes with many built-in functions. You call them the same way.

Examples include print(), len(), and type(). They are always available.


# Calling the built-in len() function
my_list = [1, 2, 3, 4]
length = len(my_list)
print(f"The list has {length} items.")

# Calling the built-in str() function
number = 42
text_version = str(number)
print(f"The text is: {text_version}")
    

The list has 4 items.
The text is: 42
    

These functions are part of the Python language. You do not need to define them yourself.

Common Mistakes and Best Practices

Beginners often make a few simple errors. Being aware of them helps.

Forgetting the parentheses is the top mistake. greet refers to the function object. greet() calls it.

Passing the wrong number of arguments will cause an error. The count must match the function's definition.


def example(a, b):
    return a + b

# This will cause a TypeError
# result = example(5)
    

Use clear and descriptive names for your functions. This makes your code easier to read.

For advanced techniques on handling arguments, explore our guide on Python Function Argument Unpacking.

Conclusion

Calling a function in Python is straightforward. Use the function name followed by parentheses.

You can pass arguments into the parentheses. You can also capture the value the function returns.

Mastering function calls is a major step in programming. It lets you use both your own code and Python's built-in tools effectively.

Practice by writing small functions. Call them with different arguments. See how they behave. This is the best way to learn.