DEV Community

Cover image for What are parameters and arguments?
Aweys Ahmed
Aweys Ahmed

Posted on • Edited on

5

What are parameters and arguments?

You'll definitely hear the words parameter and argument during your coding journey. In some cases, you may hear them being used interchangeably, however, they are different but closely related.

Let's use an example to get a better understanding of parameter and argument.

When you are declaring a function, you will state the parameters required for it to work.

def multiply(x, y)
  x * y
end

# x and y are the parameters
Enter fullscreen mode Exit fullscreen mode

In the above example, we created a function that has two parameters, x and y. A parameter is what is required to make the function work when it is declared

An argument is what is actually passed to the function when it is being called.

multiply(2,3)

# 2 and 3 are the arguments
# output 6 
Enter fullscreen mode Exit fullscreen mode

When we use a function and pass in data, then it is called an argument. So we passed two arguments to the multiply function.

I hope this helps clarify the use of these two terms.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (2)

Collapse
 
ljbarnes profile image
Leah Barnes

Helpful and explained clearly--thanks!

Collapse
 
aweysahmed profile image
Aweys Ahmed

Thank you for the kind feedback. :)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay