Arguments/Parameters

Arguments
Β 
areΒ 
theΒ 
inputΒ 
forΒ 
aΒ 
function.
TheyΒ 
areΒ 
givenΒ 
insideΒ 
theΒ 
parenthesesΒ 
(Β 
)
Β 
inΒ 
aΒ 
function.
TheseΒ 
valuesΒ 
canΒ 
beΒ 
usedΒ 
withinΒ 
theΒ 
function.
TheΒ 
numberΒ 
ofΒ 
argumentsΒ 
requiredΒ 
inΒ 
aΒ 
functionΒ 
isΒ 
definedΒ 
whileΒ 
weΒ 
createΒ 
aΒ 
function.
def function_name(arguments):
    <function body>
def add(num1, num2):
    total = num1 + num2
    print(total)
add(1,2)

List as arguments

InsteadΒ 
ofΒ 
givingΒ 
multipleΒ 
arguments,Β 
weΒ 
canΒ 
passΒ 
aΒ 
list
Β 
asΒ 
aΒ 
singleΒ 
argumentΒ 
thatΒ 
holdsΒ 
multiple
Β 
values
.
TheΒ 
listΒ 
isΒ 
thenΒ 
accessedΒ 
insideΒ 
theΒ 
functionΒ 
viaΒ 
indexing
.
def function_name(list_argument):
    <function body>
my_list = [1,2]
def add(list_num):
    total = 0
    for i in list_num:
        total = total + i
    print(total)
add(my_list)
#my_list will be passed to list_num, and it will be used inside the function

*args

ByΒ 
passingΒ 
*args
Β 
asΒ 
anΒ 
argumentΒ 
toΒ 
aΒ 
function,Β 
PythonΒ 
allowsΒ 
usΒ 
toΒ 
passΒ 
any
Β 
number
Β 
ofΒ 
arguments
Β 
toΒ 
aΒ 
function,Β 
andΒ 
itΒ 
willΒ 
storeΒ 
themΒ 
inΒ 
argsΒ 
likeΒ 
aΒ 
List
.
def function_name(*args):
    <function body>
def add(*args):
    total=0
    for i in args:
        total = total + i
    print(total)
add(1,2,3,4)