Python

Parameters & Arguments

Learn how to pass data into functions. Master positional arguments, keyword arguments, and default values.

By TechCoder TeamLast updated: 2026-06-02
In a Nutshell

Learn how to pass data into functions. Master positional arguments, keyword arguments, and default values. This hands-on tutorial focuses on practical implementation of parameters & arguments concepts.

Parameters & Arguments

Functions become powerful when they can accept data. This is done using Parameters and Arguments.

  • Parameter: The variable listed inside the parentheses in the function definition.
  • Argument: The value that is sent to the function when it is called.

Positional Arguments

By default, arguments must be passed in the correct order.

PYTHON PLAYGROUND
⏳ Loading editor…

Keyword Arguments

You can pass arguments by key=value syntax. In this case, the order doesn't matter.

PYTHON PLAYGROUND
⏳ Loading editor…

Default Values

You can define a default value for a parameter. If the caller doesn't provide an argument, the default is used.

PYTHON PLAYGROUND
⏳ Loading editor…

Advanced: Positional-Only and Keyword-Only Parameters ⚡

Python 3.8+ introduced special syntax to enforce how arguments can be passed.

Positional-Only (/)

Parameters before / MUST be passed positionally.

PYTHON PLAYGROUND
⏳ Loading editor…

Keyword-Only (*)

Parameters after * MUST be passed as keywords.

PYTHON PLAYGROUND
⏳ Loading editor…

Mutable Default Arguments Pitfall ⚠️

NEVER use mutable objects (like lists or dicts) as default values! They persist across function calls.

PYTHON PLAYGROUND
⏳ Loading editor…

Unpacking Arguments with * and **

You can unpack lists and dictionaries when calling functions.

PYTHON PLAYGROUND
⏳ Loading editor…

Coding Challenge: Flexible Greeting System 🎭

Create a function greet_user that:

  • Takes a name (required)
  • Takes a greeting (keyword-only, default "Hello")
  • Takes any number of additional info items (*args)
  • Prints a formatted greeting
PYTHON PLAYGROUND
⏳ Loading editor…

AI Mentor

Confused about "Python function parameters arguments and default values"? Ask our AI mentor for a simplified explanation.

Quiz

Quiz

Question 1 of 5

What is the difference between a parameter and an argument?

They are the same thing
Parameter is in definition, Argument is in call
Argument is in definition, Parameter is in call
Parameters are always strings

Key Takeaways

Parameters define what data a function accepts.
Arguments are the actual data passed.
✅ Use / for positional-only and * for keyword-only parameters.
Never use mutable defaults ([], {}).
✅ Use * and ** to unpack arguments.

What's Next?

Now that we can send data in, let's learn how to get data out using Return Values.

Keep coding! 🚀