Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 404dca2

Browse files
01.01.24
1 parent e973c75 commit 404dca2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,13 @@ Output:
358358
```
359359
<br>
360360

361-
## 8. Discuss the usage of `args` and `kwargs` in _function definitions_.
361+
## 8. Discuss the usage of `*args` and `**kwargs` in _function definitions_.
362362

363363
In Python, **args** and **kwargs** are terms used to indicate that a function can accept a variable number of arguments and parameters, respectively.
364364

365-
### `args`: Variable Positional Arguments
365+
### `*args`: Variable Positional Arguments
366366

367-
`args` is used to capture an arbitrary or zero number of **positional arguments**. When calling a function with 'args', the arguments are collected into a tuple within the function. This parameter allows for a flexible number of arguments to be processed.
367+
`*args` is used to capture an arbitrary or zero number of **positional arguments**. When calling a function with '*args', the arguments are collected into a tuple within the function. This parameter allows for a flexible number of arguments to be processed.
368368

369369
Here's an example:
370370

@@ -375,9 +375,9 @@ def sum_all(*args):
375375
print(sum_all(1, 2, 3)) # Output: 6
376376
```
377377

378-
### `kwargs`: Variable Keyword Arguments
378+
### `**kwargs`: Variable Keyword Arguments
379379

380-
`kwargs` is utilized to capture an arbitrary or zero number of **keyword arguments**. When calling a function with `kwargs`, the arguments are collected into a dictionary within the function. The double star indicates that it's a keyword argument.
380+
`**kwargs` is utilized to capture an arbitrary or zero number of **keyword arguments**. When calling a function with `**kwargs`, the arguments are collected into a dictionary within the function. The double star indicates that it's a keyword argument.
381381

382382
This feature is especially handy when developers are unsure about the exact nature or number of keyword arguments that will be transmitted.
383383

@@ -395,7 +395,7 @@ display_info(name="Alice", age=25, location="New York")
395395
# location: New York
396396
```
397397

398-
### Using `args` and `kwargs` Together
398+
### Using `*args` and `**kwargs` Together
399399

400400
Developers also have the **flexibility** to use both `*args` and `**kwargs` together in a function definition, allowing them to handle a mix of positional and keyword arguments.
401401

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /