Introduction
In Python, positional arguments are arguments that are passed to a function in a specific order. The function assigns values to parameters based on their position in the function call. The order of these arguments matters, and incorrect placement can lead to unexpected results or errors.

In this article, you will learn how positional arguments work, their syntax, and best practices for using them effectively in Python functions.
Positional Arguments
A positional argument is an argument that is passed to a function based on its position. When calling a function, values must be passed in the same order as the parameters are defined.
Syntax
# Defining a function with positional arguments
def greet(name, age):
print(f"Hello, my name is {name} and I am {age} years old.")
# Calling the function with positional arguments
greet("Alice", 25)
Output:
Hello, my name is Alice and I am 25 years old.
Explanation:
- The function greet() takes two arguments: name and age.
- We passed the values "Alice" and 25 in the same order as the function parameters.
- If we change the order of arguments, the output will be different.
# Changing the order
greet(25, "Alice")
Output:
Hello, my name is 25 and I am Alice years old.
Since name expects a string and age expects an integer, switching them leads to incorrect output.
Example of Positional Arguments
Let's consider another example where we define a function to calculate the area of a rectangle.
# Function to calculate the area of a rectangle
def area(length, width):
return length * width
# Calling the function
result = area(10, 5)
print("Area of rectangle:", result)
Output:
Area of rectangle: 50
Explanation:
- The function area() takes two arguments: length and width.
- We passed the values 10 and 5 as positional arguments.
- The function correctly calculates the area as 10 × 5 = 50.
If we mistakenly switch the order of arguments, it will not affect the result in this case. However, in some cases, swapping positional arguments may cause errors or incorrect results.



