
PYTHON — Positional Arguments in Python
The computer was born to solve problems that did not exist before. — Bill Gates

PYTHON — Python Assertion Documentation- Code
Positional arguments are one of the fundamental concepts in Python that allow you to provide data to a function. This flexibility enables the function to run differently each time it is called, based on the provided arguments. In this tutorial, we will cover the basics of using positional arguments in Python.
To start, let’s define a simple function that takes three positional arguments: qty, item, and price. The function will then display a statement that indicates how much the specified quantity of a particular item costs. Below is the code for the function:
def f(qty, item, price):
print(f"{qty} {item} cost ${price:.2f}")In the above code, we use an f-string to format the output, where {qty}, {item}, and {price:.2f} are placeholders for the values of the qty, item, and price arguments, respectively.
Next, let’s make a function call by providing values for the qty, item, and price arguments. This is how a function call with positional arguments looks:
f(6, 'banana', 1.74)In the function call, the values 6, 'banana', and 1.74 are assigned to the qty, item, and price parameters, respectively. As a result, the function will display the output based on these provided values.
It’s important to note that the order in which you specify the values for positional arguments matters. For example, if you change the order of the arguments in the function call, the values will be assigned to the parameters based on their positions. Here’s an example of a function call with arguments in a different order:
f('banana', 6, 1.74)In this case, 'banana' will be assigned to qty, 6 will be assigned to item, and 1.74 will be assigned to price, resulting in a different output.
If you provide the wrong number of arguments or if the arguments are not in the expected order, it can lead to errors. For instance, providing too few or too many arguments will result in an error.
In summary, positional arguments in Python allow you to specify argument values based on their positions when calling a function. Understanding how to use positional arguments is essential for working with functions in Python.

