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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

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. :)

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

👋 Kindness is contagious

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

Okay