The use of a single asterisk (*) before the parameter name (arg) indicates that it can accept a variable number of unnamed positional arguments. When the function is called, these arguments will be collected into a tuple named arg.
The **args parameter, with two asterisks (**), allows for a variable number of keyword arguments to be passed to the function. These arguments will be collected into a dictionary named args.
B is not the Valid answer. But A is valid one. because *args or *arg in python hold possition argument as turple and not as list. So its false to say *args hold information as list.
A is correct.
B is wrong since *arg is a tuple, not a list
C is wrong since *arg is the placeholder for unnamed arguments
D is wrong since the parameter names can be changed
code:
def f1(*arg, **args):
print(arg, type(arg))
print(args, type(args))
f1(1, 2, 3, a=1, b=2, c=3)
output:
(1, 2, 3) <class 'tuple'>
{'a': 1, 'b': 2, 'c': 3} <class 'dict'>
What happens here is that **args is the same variable as *args. Therefore, the placeholder for positional arguments (unnamed arguments) is replaced by the named arguments. Correct answer is C
Wrong. C is incorrect.
They are two different variables, one is named "arg", the other "args".
*arg holds the unnamed arguments
**args hold the named arguments.
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
cubesmi
Highly Voted 1 year, 5 months agoherrmann69
5 months, 3 weeks ago2211094
Most Recent 1 month, 3 weeks ago2211094
2 months agoDiscussoR
4 months agoherrmann69
5 months, 3 weeks agomademade
6 months, 3 weeks agorafles
1 year, 4 months agoherrmann69
5 months, 3 weeks ago