0% found this document useful (0 votes)
52 views6 pages

Parameter Passing in Python

Uploaded by

jemsson66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views6 pages

Parameter Passing in Python

Uploaded by

jemsson66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Parameter Passing in Python

Welcome to this Python parameter passing presentation. Today, we'll dive into
the different ways you can pass information into your Python functions.

MI by Md Jahirul Islam
Positional Arguments
Order Matters Example
Positional arguments are passed in the order they appear in the In the function `greet(name, age)`, the first argument is the
function definition. name and the second is the age.
Keyword Arguments
1 Named Arguments 2 Flexibility
Keyword arguments are You can pass arguments in
passed by name using any order, as long as you use
`name=value` syntax. their names.

3 Default Values
Keyword arguments can have default values if they are not provided
when calling the function.
Default Arguments
Optional Parameters Example
Default arguments provide a In `greet(name,
default value for a parameter if greeting="Hello")`, `greeting`
none is specified. defaults to "Hello" if not provided.

Flexibility
You can customize the greeting without always having to specify it.
Arbitrary Arguments (*args)

Variable-Length Arguments
Use `*args` to accept an arbitrary number of positional arguments.

Flexibility
The function can handle any number of inputs, which is useful for dynamic
situations.

Tuple Collection
The `*args` argument is a tuple containing all the positional arguments
passed.
Keyword Arguments (**kwargs)

1 Dictionary Input

2 Flexible Parameters

3 Keyword-Based

Use `**kwargs` to accept an arbitrary number of keyword arguments. These arguments are stored in a dictionary. You can access the
arguments using key-value pairs.

You might also like